aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2013-10-06 02:41:22 +0200
committerhjk <hjk121@nokiamail.com>2013-10-15 16:22:28 +0200
commit2b532c73ee96314c4af5d7ff0ecd4c31c6f81730 (patch)
tree3d7d4fc1adb7800a13fdf2ca37fee9f1ed485d76
parent0a600e041afd7478aef528c61776a0fc660fd175 (diff)
CPlusPlus: Make (sub-)languague selection more generic
Change-Id: I4e2df6992b446adec662ab07671acd41715e41fd Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
-rw-r--r--src/libs/3rdparty/cplusplus/Bind.cpp12
-rw-r--r--src/libs/3rdparty/cplusplus/Keywords.cpp133
-rw-r--r--src/libs/3rdparty/cplusplus/Lexer.cpp22
-rw-r--r--src/libs/3rdparty/cplusplus/Lexer.h19
-rw-r--r--src/libs/3rdparty/cplusplus/Parser.cpp145
-rw-r--r--src/libs/3rdparty/cplusplus/Parser.h13
-rw-r--r--src/libs/3rdparty/cplusplus/Token.h16
-rw-r--r--src/libs/3rdparty/cplusplus/TranslationUnit.cpp26
-rw-r--r--src/libs/3rdparty/cplusplus/TranslationUnit.h16
-rw-r--r--src/libs/cplusplus/BackwardsScanner.cpp9
-rw-r--r--src/libs/cplusplus/CppDocument.cpp10
-rw-r--r--src/libs/cplusplus/SimpleLexer.cpp52
-rw-r--r--src/libs/cplusplus/SimpleLexer.h15
-rw-r--r--src/plugins/cppeditor/cppautocompleter.cpp10
-rw-r--r--src/plugins/cppeditor/cppfollowsymbolundercursor.cpp7
-rw-r--r--src/plugins/cppeditor/cpphighlighter.cpp8
-rw-r--r--src/plugins/cpptools/cppcodeformatter.cpp9
-rw-r--r--src/plugins/cpptools/cppcompletionassist.cpp28
-rw-r--r--src/plugins/cpptools/cppcompletionassist.h2
-rw-r--r--src/plugins/cpptools/cpphighlightingsupportinternal.cpp11
-rw-r--r--tests/auto/cplusplus/ast/tst_ast.cpp9
-rw-r--r--tests/auto/cplusplus/cxx11/tst_cxx11.cpp4
-rw-r--r--tests/auto/cplusplus/semantic/tst_semantic.cpp16
23 files changed, 272 insertions, 320 deletions
diff --git a/src/libs/3rdparty/cplusplus/Bind.cpp b/src/libs/3rdparty/cplusplus/Bind.cpp
index eb34bba396..a00bdc97c3 100644
--- a/src/libs/3rdparty/cplusplus/Bind.cpp
+++ b/src/libs/3rdparty/cplusplus/Bind.cpp
@@ -347,7 +347,8 @@ FullySpecifiedType Bind::declarator(DeclaratorAST *ast, const FullySpecifiedType
std::swap(_declaratorId, declaratorId);
bool isAuto = false;
- if (translationUnit()->cxx0xEnabled())
+ const bool cxx11Enabled = translationUnit()->languageFeatures().cxx11Enabled;
+ if (cxx11Enabled)
isAuto = type.isAuto();
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
@@ -369,8 +370,7 @@ FullySpecifiedType Bind::declarator(DeclaratorAST *ast, const FullySpecifiedType
}
if (!type->isFunctionType()) {
ExpressionTy initializer = this->expression(ast->initializer);
- if (translationUnit()->cxx0xEnabled() && isAuto) {
-
+ if (cxx11Enabled && isAuto) {
type = initializer;
type.setAuto(true);
}
@@ -1249,7 +1249,7 @@ bool Bind::visit(ForeachStatementAST *ast)
DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId);
const StringLiteral *initializer = 0;
- if (type.isAuto() && translationUnit()->cxx0xEnabled()) {
+ if (type.isAuto() && translationUnit()->languageFeatures().cxx11Enabled) {
ExpressionTy exprType = this->expression(ast->expression);
ArrayType* arrayType = 0;
@@ -1299,7 +1299,7 @@ bool Bind::visit(RangeBasedForStatementAST *ast)
DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId);
const StringLiteral *initializer = 0;
- if (type.isAuto() && translationUnit()->cxx0xEnabled()) {
+ if (type.isAuto() && translationUnit()->languageFeatures().cxx11Enabled) {
ExpressionTy exprType = this->expression(ast->expression);
ArrayType* arrayType = 0;
@@ -2722,7 +2722,7 @@ bool Bind::visit(SimpleSpecifierAST *ast)
break;
case T_AUTO:
- if (!translationUnit()->cxx0xEnabled()) {
+ if (!translationUnit()->languageFeatures().cxx11Enabled) {
if (_type.isAuto())
translationUnit()->error(ast->specifier_token, "duplicate `%s'", spell(ast->specifier_token));
}
diff --git a/src/libs/3rdparty/cplusplus/Keywords.cpp b/src/libs/3rdparty/cplusplus/Keywords.cpp
index 1da78381ac..91c9ffc312 100644
--- a/src/libs/3rdparty/cplusplus/Keywords.cpp
+++ b/src/libs/3rdparty/cplusplus/Keywords.cpp
@@ -21,9 +21,10 @@
#include "Lexer.h"
#include "Token.h"
-using namespace CPlusPlus;
+namespace CPlusPlus {
-static inline int classify2(const char *s, bool, bool) {
+static inline int classify2(const char *s, LanguageFeatures)
+{
if (s[0] == 'd') {
if (s[1] == 'o') {
return T_DO;
@@ -37,7 +38,8 @@ static inline int classify2(const char *s, bool, bool) {
return T_IDENTIFIER;
}
-static inline int classify3(const char *s, bool q, bool) {
+static inline int classify3(const char *s, LanguageFeatures features)
+{
if (s[0] == 'a') {
if (s[1] == 's') {
if (s[2] == 'm') {
@@ -73,7 +75,7 @@ static inline int classify3(const char *s, bool q, bool) {
}
}
}
- else if (q && s[0] == 'Q') {
+ else if (features.qtMocRunEnabled && s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'D') {
return T_Q_D;
@@ -86,7 +88,8 @@ static inline int classify3(const char *s, bool q, bool) {
return T_IDENTIFIER;
}
-static inline int classify4(const char *s, bool q, bool) {
+static inline int classify4(const char *s, LanguageFeatures features)
+{
if (s[0] == 'a') {
if (s[1] == 'u') {
if (s[2] == 't') {
@@ -136,7 +139,7 @@ static inline int classify4(const char *s, bool q, bool) {
}
}
}
- else if (q && s[1] == 'm') {
+ else if (features.qtKeywordsEnabled && s[1] == 'm') {
if (s[2] == 'i') {
if (s[3] == 't') {
return T_EMIT;
@@ -187,7 +190,7 @@ static inline int classify4(const char *s, bool q, bool) {
}
}
}
- else if (q && s[0] == 'S') {
+ else if (features.qtEnabled && s[0] == 'S') {
if (s[1] == 'L') {
if (s[2] == 'O') {
if (s[3] == 'T') {
@@ -199,7 +202,8 @@ static inline int classify4(const char *s, bool q, bool) {
return T_IDENTIFIER;
}
-static inline int classify5(const char *s, bool q, bool) {
+static inline int classify5(const char *s, LanguageFeatures features)
+{
if (s[0] == '_') {
if (s[1] == '_') {
if (s[2] == 'a') {
@@ -281,7 +285,7 @@ static inline int classify5(const char *s, bool q, bool) {
}
}
}
- else if (q) {
+ else if (features.qtKeywordsEnabled) {
if (s[1] == 'l') {
if (s[2] == 'o') {
if (s[3] == 't') {
@@ -338,7 +342,8 @@ static inline int classify5(const char *s, bool q, bool) {
return T_IDENTIFIER;
}
-static inline int classify6(const char *s, bool q, bool) {
+static inline int classify6(const char *s, LanguageFeatures features)
+{
if (s[0] == 'd') {
if (s[1] == 'e') {
if (s[2] == 'l') {
@@ -508,7 +513,7 @@ static inline int classify6(const char *s, bool q, bool) {
}
}
}
- else if (q && s[0] == 'S') {
+ else if (features.qtKeywordsEnabled && s[0] == 'S') {
if (s[1] == 'I') {
if (s[2] == 'G') {
if (s[3] == 'N') {
@@ -521,7 +526,7 @@ static inline int classify6(const char *s, bool q, bool) {
}
}
}
- else if (q && s[0] == 'Q') {
+ else if (features.qtKeywordsEnabled && s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'S') {
if (s[3] == 'L') {
@@ -546,7 +551,8 @@ static inline int classify6(const char *s, bool q, bool) {
return T_IDENTIFIER;
}
-static inline int classify7(const char *s, bool q, bool x) {
+static inline int classify7(const char *s, LanguageFeatures features)
+{
if (s[0] == '_') {
if (s[1] == '_') {
if (s[2] == 'a') {
@@ -573,7 +579,7 @@ static inline int classify7(const char *s, bool q, bool x) {
}
}
}
- else if (x && s[0] == 'a') {
+ else if (features.cxx11Enabled && s[0] == 'a') {
if (s[1] == 'l') {
if (s[2] == 'i') {
if (s[3] == 'g') {
@@ -623,7 +629,7 @@ static inline int classify7(const char *s, bool q, bool x) {
}
}
}
- else if (x && s[0] == 'n') {
+ else if (features.cxx11Enabled && s[0] == 'n') {
if (s[1] == 'u') {
if (s[2] == 'l') {
if (s[3] == 'l') {
@@ -653,7 +659,7 @@ static inline int classify7(const char *s, bool q, bool x) {
}
}
}
- else if (q && s[0] == 'f') {
+ else if (features.qtKeywordsEnabled && s[0] == 'f') {
if (s[1] == 'o') {
if (s[2] == 'r') {
if (s[3] == 'e') {
@@ -668,7 +674,7 @@ static inline int classify7(const char *s, bool q, bool x) {
}
}
}
- else if (q && s[0] == 's') {
+ else if (features.qtEnabled && s[0] == 's') {
if (s[1] == 'i') {
if (s[2] == 'g') {
if (s[3] == 'n') {
@@ -728,7 +734,7 @@ static inline int classify7(const char *s, bool q, bool x) {
}
}
}
- else if (q && s[0] == 'Q') {
+ else if (features.qtEnabled && s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'S') {
if (s[3] == 'L') {
@@ -768,7 +774,8 @@ static inline int classify7(const char *s, bool q, bool x) {
return T_IDENTIFIER;
}
-static inline int classify8(const char *s, bool q, bool x) {
+static inline int classify8(const char *s, LanguageFeatures features)
+{
if (s[0] == '_') {
if (s[1] == '_') {
if (s[2] == 'i') {
@@ -814,7 +821,7 @@ static inline int classify8(const char *s, bool q, bool x) {
}
}
}
- } else if (x && s[1] == 'h') {
+ } else if (features.cxx11Enabled && s[1] == 'h') {
if (s[2] == 'a') {
if (s[3] == 'r') {
if (s[4] == '1') {
@@ -838,7 +845,7 @@ static inline int classify8(const char *s, bool q, bool x) {
}
}
}
- else if (x && s[0] == 'd') {
+ else if (features.cxx11Enabled && s[0] == 'd') {
if (s[1] == 'e') {
if (s[2] == 'c') {
if (s[3] == 'l') {
@@ -872,7 +879,7 @@ static inline int classify8(const char *s, bool q, bool x) {
}
}
}
- else if (x && s[0] == 'n') {
+ else if (features.cxx11Enabled && s[0] == 'n') {
if (s[1] == 'o') {
if (s[2] == 'e') {
if (s[3] == 'x') {
@@ -989,7 +996,7 @@ static inline int classify8(const char *s, bool q, bool x) {
}
}
}
- else if (q && s[0] == 'Q') {
+ else if (features.qtEnabled && s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'G') {
if (s[3] == 'A') {
@@ -1035,7 +1042,8 @@ static inline int classify8(const char *s, bool q, bool x) {
return T_IDENTIFIER;
}
-static inline int classify9(const char *s, bool q, bool x) {
+static inline int classify9(const char *s, LanguageFeatures features)
+{
if (s[0] == '_') {
if (s[1] == '_') {
if (s[2] == 'c') {
@@ -1055,7 +1063,7 @@ static inline int classify9(const char *s, bool q, bool x) {
}
}
}
- else if (x && s[0] == 'c') {
+ else if (features.cxx11Enabled && s[0] == 'c') {
if (s[1] == 'o') {
if (s[2] == 'n') {
if (s[3] == 's') {
@@ -1112,7 +1120,7 @@ static inline int classify9(const char *s, bool q, bool x) {
}
}
}
- else if (q && s[0] == 'Q') {
+ else if (features.qtEnabled && s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'S') {
if (s[3] == 'I') {
@@ -1148,7 +1156,8 @@ static inline int classify9(const char *s, bool q, bool x) {
return T_IDENTIFIER;
}
-static inline int classify10(const char *s, bool q, bool) {
+static inline int classify10(const char *s, LanguageFeatures features)
+{
if (s[0] == '_') {
if (s[1] == '_') {
if (s[2] == 'i') {
@@ -1242,7 +1251,7 @@ static inline int classify10(const char *s, bool q, bool) {
}
}
}
- else if (q && s[0] == 'Q') {
+ else if (features.qtEnabled && s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'O') {
if (s[3] == 'V') {
@@ -1283,7 +1292,8 @@ static inline int classify10(const char *s, bool q, bool) {
return T_IDENTIFIER;
}
-static inline int classify11(const char *s, bool q, bool) {
+static inline int classify11(const char *s, LanguageFeatures features)
+{
if (s[0] == '_') {
if (s[1] == '_') {
if (s[2] == 'a') {
@@ -1330,7 +1340,7 @@ static inline int classify11(const char *s, bool q, bool) {
}
}
}
- else if (q && s[0] == 'Q') {
+ else if (features.qtEnabled && s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'I') {
if (s[3] == 'N') {
@@ -1356,7 +1366,8 @@ static inline int classify11(const char *s, bool q, bool) {
return T_IDENTIFIER;
}
-static inline int classify12(const char *s, bool q, bool) {
+static inline int classify12(const char *s, LanguageFeatures features)
+{
if (s[0] == '_') {
if (s[1] == '_') {
if (s[2] == 'v') {
@@ -1382,7 +1393,7 @@ static inline int classify12(const char *s, bool q, bool) {
}
}
}
- else if (q && s[0] == 'Q') {
+ else if (features.qtEnabled && s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'I') {
if (s[3] == 'N') {
@@ -1435,7 +1446,8 @@ static inline int classify12(const char *s, bool q, bool) {
return T_IDENTIFIER;
}
-static inline int classify13(const char *s, bool, bool x) {
+static inline int classify13(const char *s, LanguageFeatures features)
+{
if (s[0] == '_') {
if (s[1] == '_') {
if (s[2] == 'a') {
@@ -1462,7 +1474,7 @@ static inline int classify13(const char *s, bool, bool x) {
}
}
}
- } else if (x && s[0] == 's') {
+ } else if (features.cxx11Enabled && s[0] == 's') {
if (s[1] == 't') {
if (s[2] == 'a') {
if (s[3] == 't') {
@@ -1492,7 +1504,8 @@ static inline int classify13(const char *s, bool, bool x) {
return T_IDENTIFIER;
}
-static inline int classify16(const char *s, bool, bool) {
+static inline int classify16(const char *s, LanguageFeatures)
+{
if (s[0] == 'r') {
if (s[1] == 'e') {
if (s[2] == 'i') {
@@ -1529,8 +1542,9 @@ static inline int classify16(const char *s, bool, bool) {
return T_IDENTIFIER;
}
-static inline int classify14(const char *s, bool q, bool) {
- if (q && s[0] == 'Q') {
+static inline int classify14(const char *s, LanguageFeatures features)
+{
+ if (features.qtEnabled && s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'P') {
if (s[3] == 'R') {
@@ -1562,8 +1576,9 @@ static inline int classify14(const char *s, bool q, bool) {
return T_IDENTIFIER;
}
-static inline int classify18(const char *s, bool q, bool) {
- if (q && s[0] == 'Q') {
+static inline int classify18(const char *s, LanguageFeatures features)
+{
+ if (features.qtEnabled && s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'P') {
if (s[3] == 'R') {
@@ -1603,8 +1618,9 @@ static inline int classify18(const char *s, bool q, bool) {
return T_IDENTIFIER;
}
-static inline int classify19(const char *s, bool q, bool) {
- if (q && s[0] == 'Q') {
+static inline int classify19(const char *s, LanguageFeatures features)
+{
+ if (features.qtEnabled && s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'D') {
if (s[3] == 'E') {
@@ -1647,24 +1663,24 @@ static inline int classify19(const char *s, bool q, bool) {
}
-int Lexer::classify(const char *s, int n, bool q, bool x) {
+int Lexer::classify(const char *s, int n, LanguageFeatures features) {
switch (n) {
- case 2: return classify2(s, q, x);
- case 3: return classify3(s, q, x);
- case 4: return classify4(s, q, x);
- case 5: return classify5(s, q, x);
- case 6: return classify6(s, q, x);
- case 7: return classify7(s, q, x);
- case 8: return classify8(s, q, x);
- case 9: return classify9(s, q, x);
- case 10: return classify10(s, q, x);
- case 11: return classify11(s, q, x);
- case 12: return classify12(s, q, x);
- case 13: return classify13(s, q, x);
- case 14: return classify14(s, q, x);
- case 16: return classify16(s, q, x);
- case 18: return classify18(s, q, x);
- case 19: return classify19(s, q, x);
+ case 2: return classify2(s, features);
+ case 3: return classify3(s, features);
+ case 4: return classify4(s, features);
+ case 5: return classify5(s, features);
+ case 6: return classify6(s, features);
+ case 7: return classify7(s, features);
+ case 8: return classify8(s, features);
+ case 9: return classify9(s, features);
+ case 10: return classify10(s, features);
+ case 11: return classify11(s, features);
+ case 12: return classify12(s, features);
+ case 13: return classify13(s, features);
+ case 14: return classify14(s, features);
+ case 16: return classify16(s, features);
+ case 18: return classify18(s, features);
+ case 19: return classify19(s, features);
default: return T_IDENTIFIER;
} // switch
}
@@ -1807,3 +1823,4 @@ int Lexer::classifyOperator(const char *s, int n) {
}
+} // namespace CPlusPlus
diff --git a/src/libs/3rdparty/cplusplus/Lexer.cpp b/src/libs/3rdparty/cplusplus/Lexer.cpp
index 66baa54e65..6e6e6c2feb 100644
--- a/src/libs/3rdparty/cplusplus/Lexer.cpp
+++ b/src/libs/3rdparty/cplusplus/Lexer.cpp
@@ -81,24 +81,6 @@ int Lexer::state() const
void Lexer::setState(int state)
{ _state = state; }
-bool Lexer::qtMocRunEnabled() const
-{ return f._qtMocRunEnabled; }
-
-void Lexer::setQtMocRunEnabled(bool onoff)
-{ f._qtMocRunEnabled = onoff; }
-
-bool Lexer::cxx0xEnabled() const
-{ return f._cxx0xEnabled; }
-
-void Lexer::setCxxOxEnabled(bool onoff)
-{ f._cxx0xEnabled = onoff; }
-
-bool Lexer::objCEnabled() const
-{ return f._objCEnabled; }
-
-void Lexer::setObjCEnabled(bool onoff)
-{ f._objCEnabled = onoff; }
-
bool Lexer::isIncremental() const
{ return f._isIncremental; }
@@ -557,7 +539,7 @@ void Lexer::scan_helper(Token *tok)
break;
default: {
- if (f._objCEnabled) {
+ if (_languageFeatures.objCEnabled) {
if (ch == '@' && _yychar >= 'a' && _yychar <= 'z') {
const char *yytext = _currentChar;
@@ -780,7 +762,7 @@ void Lexer::scanIdentifier(Token *tok, unsigned extraProcessedChars)
yyinp();
int yylen = _currentChar - yytext;
if (f._scanKeywords)
- tok->f.kind = classify(yytext, yylen, f._qtMocRunEnabled, f._cxx0xEnabled);
+ tok->f.kind = classify(yytext, yylen, _languageFeatures);
else
tok->f.kind = T_IDENTIFIER;
diff --git a/src/libs/3rdparty/cplusplus/Lexer.h b/src/libs/3rdparty/cplusplus/Lexer.h
index cbea3be06a..63236104e8 100644
--- a/src/libs/3rdparty/cplusplus/Lexer.h
+++ b/src/libs/3rdparty/cplusplus/Lexer.h
@@ -45,15 +45,6 @@ public:
Control *control() const { return _control; }
TranslationUnit *translationUnit() const;
- bool qtMocRunEnabled() const;
- void setQtMocRunEnabled(bool onoff);
-
- bool cxx0xEnabled() const;
- void setCxxOxEnabled(bool onoff);
-
- bool objCEnabled() const;
- void setObjCEnabled(bool onoff);
-
void scan(Token *tok);
inline void operator()(Token *tok)
@@ -82,10 +73,13 @@ public:
bool isIncremental() const;
void setIncremental(bool isIncremental);
+ LanguageFeatures languageFeatures() const { return _languageFeatures; }
+ void setLanguageFeatures(LanguageFeatures features) { _languageFeatures = features; }
+
private:
void scan_helper(Token *tok);
void setSource(const char *firstChar, const char *lastChar);
- static int classify(const char *string, int length, bool q, bool cxx0x);
+ static int classify(const char *string, int length, LanguageFeatures features);
static int classifyObjCAtKeyword(const char *s, int n);
static int classifyOperator(const char *string, int length);
@@ -111,9 +105,6 @@ private:
unsigned _scanCommentTokens: 1;
unsigned _scanKeywords: 1;
unsigned _scanAngleStringLiteralTokens: 1;
- unsigned _qtMocRunEnabled: 1;
- unsigned _cxx0xEnabled: 1;
- unsigned _objCEnabled: 1;
};
TranslationUnit *_translationUnit;
@@ -129,6 +120,8 @@ private:
Flags f;
};
unsigned _currentLine;
+ LanguageFeatures _languageFeatures;
+
};
} // namespace CPlusPlus
diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp
index bf79803854..c4b4072e83 100644
--- a/src/libs/3rdparty/cplusplus/Parser.cpp
+++ b/src/libs/3rdparty/cplusplus/Parser.cpp
@@ -169,13 +169,11 @@ inline bool isRightAssociative(int tokenKind)
Parser::Parser(TranslationUnit *unit)
: _translationUnit(unit),
- _control(_translationUnit->control()),
- _pool(_translationUnit->memoryPool()),
+ _control(unit->control()),
+ _pool(unit->memoryPool()),
+ _languageFeatures(unit->languageFeatures()),
_tokenIndex(1),
_templateArguments(0),
- _qtMocRunEnabled(false),
- _cxx0xEnabled(false),
- _objCEnabled(false),
_inFunctionBody(false),
_inObjCImplementationContext(false),
_inExpressionStatement(false),
@@ -186,24 +184,6 @@ Parser::Parser(TranslationUnit *unit)
Parser::~Parser()
{ }
-bool Parser::qtMocRunEnabled() const
-{ return _qtMocRunEnabled; }
-
-void Parser::setQtMocRunEnabled(bool onoff)
-{ _qtMocRunEnabled = onoff; }
-
-bool Parser::cxx0xEnabled() const
-{ return _cxx0xEnabled; }
-
-void Parser::setCxxOxEnabled(bool onoff)
-{ _cxx0xEnabled = onoff; }
-
-bool Parser::objCEnabled() const
-{ return _objCEnabled; }
-
-void Parser::setObjCEnabled(bool onoff)
-{ _objCEnabled = onoff; }
-
bool Parser::switchTemplateArguments(bool templateArguments)
{
bool previousTemplateArguments = _templateArguments;
@@ -336,7 +316,7 @@ bool Parser::skipUntilStatement()
case T_AT_TRY:
case T_AT_SYNCHRONIZED:
case T_AT_THROW:
- if (objCEnabled())
+ if (_languageFeatures.objCEnabled)
return true;
default:
@@ -640,17 +620,17 @@ bool Parser::parseDeclaration(DeclarationAST *&node)
break;
case T_INLINE:
- if (_cxx0xEnabled && LA(2) == T_NAMESPACE)
+ if (_languageFeatures.cxx11Enabled && LA(2) == T_NAMESPACE)
return parseNamespace(node);
return parseSimpleDeclaration(node);
case T_STATIC_ASSERT:
- if (_cxx0xEnabled)
+ if (_languageFeatures.cxx11Enabled)
return parseStaticAssertDeclaration(node);
return parseSimpleDeclaration(node);
default: {
- if (_objCEnabled && LA() == T___ATTRIBUTE__) {
+ if (_languageFeatures.objCEnabled && LA() == T___ATTRIBUTE__) {
const unsigned start = cursor();
SpecifierListAST *attributes = 0, **attr = &attributes;
while (parseAttributeSpecifier(*attr))
@@ -753,11 +733,11 @@ bool Parser::parseStaticAssertDeclaration(DeclarationAST *&node)
bool Parser::parseNamespace(DeclarationAST *&node)
{
DEBUG_THIS_RULE();
- if (LA() != T_NAMESPACE && !(_cxx0xEnabled && LA() == T_INLINE && LA(2) == T_NAMESPACE))
+ if (LA() != T_NAMESPACE && !(_languageFeatures.cxx11Enabled && LA() == T_INLINE && LA(2) == T_NAMESPACE))
return false;
unsigned inline_token = 0;
- if (cxx0xEnabled() && LA() == T_INLINE)
+ if (_languageFeatures.cxx11Enabled && LA() == T_INLINE)
inline_token = consumeToken();
unsigned namespace_token = consumeToken();
@@ -826,7 +806,7 @@ bool Parser::parseUsing(DeclarationAST *&node)
if (LA(2) == T_NAMESPACE)
return parseUsingDirective(node);
- if (_cxx0xEnabled && LA(2) == T_IDENTIFIER && parseAliasDeclaration(node))
+ if (_languageFeatures.cxx11Enabled && LA(2) == T_IDENTIFIER && parseAliasDeclaration(node))
return true;
UsingAST *ast = new (_pool) UsingAST;
@@ -953,12 +933,13 @@ bool Parser::parseTemplateArgumentList(ExpressionListAST *&node)
ExpressionListAST **template_argument_ptr = &node;
ExpressionAST *template_argument = 0;
+ const bool cxx11Enabled = _languageFeatures.cxx11Enabled;
if (parseTemplateArgument(template_argument)) {
*template_argument_ptr = new (_pool) ExpressionListAST;
(*template_argument_ptr)->value = template_argument;
template_argument_ptr = &(*template_argument_ptr)->next;
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT)
+ if (cxx11Enabled && LA() == T_DOT_DOT_DOT)
consumeToken(); // ### store this token in the AST
while (LA() == T_COMMA) {
@@ -969,7 +950,7 @@ bool Parser::parseTemplateArgumentList(ExpressionListAST *&node)
(*template_argument_ptr)->value = template_argument;
template_argument_ptr = &(*template_argument_ptr)->next;
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT)
+ if (cxx11Enabled && LA() == T_DOT_DOT_DOT)
consumeToken(); // ### store this token in the AST
}
}
@@ -1230,7 +1211,7 @@ bool Parser::parseRefQualifier(unsigned &ref_qualifier)
{
DEBUG_THIS_RULE();
- if (!_cxx0xEnabled)
+ if (!_languageFeatures.cxx11Enabled)
return false;
if (LA() == T_AMPER || LA() == T_AMPER_AMPER) {
@@ -1248,7 +1229,7 @@ bool Parser::parseOverrideFinalQualifiers(SpecifierListAST *&node)
{
DEBUG_THIS_RULE();
- if (!_cxx0xEnabled)
+ if (!_languageFeatures.cxx11Enabled)
return false;
unsigned start = cursor();
@@ -1278,7 +1259,7 @@ bool Parser::parseOverrideFinalQualifiers(SpecifierListAST *&node)
bool Parser::parsePtrOperator(PtrOperatorListAST *&node)
{
DEBUG_THIS_RULE();
- if (LA() == T_AMPER || (_cxx0xEnabled && LA() == T_AMPER_AMPER)) {
+ if (LA() == T_AMPER || (_languageFeatures.cxx11Enabled && LA() == T_AMPER_AMPER)) {
ReferenceAST *ast = new (_pool) ReferenceAST;
ast->reference_token = consumeToken();
node = new (_pool) PtrOperatorListAST(ast);
@@ -1319,7 +1300,7 @@ bool Parser::parseTemplateArgument(ExpressionAST *&node)
if (parseTypeId(node)) {
int index = 1;
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT)
+ if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT)
index = 2;
if (LA(index) == T_COMMA || maybeSplitGreaterGreaterToken(index) || LA(index) == T_GREATER)
@@ -1413,7 +1394,7 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_sp
ptr_operators_tail = &(*ptr_operators_tail)->next;
if (LA() == T_COLON_COLON || LA() == T_IDENTIFIER || LA() == T_TILDE || LA() == T_OPERATOR
- || (_cxx0xEnabled && LA() == T_DOT_DOT_DOT && (LA(2) == T_COLON_COLON || LA(2) == T_IDENTIFIER))) {
+ || (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT && (LA(2) == T_COLON_COLON || LA(2) == T_IDENTIFIER))) {
unsigned dot_dot_dot_token = 0;
@@ -1543,7 +1524,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specif
parseRefQualifier(ast->ref_qualifier_token);
parseExceptionSpecification(ast->exception_specification);
- if (_cxx0xEnabled && ! node->ptr_operator_list && LA() == T_ARROW) {
+ if (_languageFeatures.cxx11Enabled && ! node->ptr_operator_list && LA() == T_ARROW) {
// only allow if there is 1 type spec, which has to be 'auto'
bool hasAuto = false;
for (SpecifierListAST *iter = decl_specifier_list; !hasAuto && iter; iter = iter->next) {
@@ -1690,12 +1671,12 @@ bool Parser::parseEnumSpecifier(SpecifierListAST *&node)
EnumSpecifierAST *ast = new (_pool) EnumSpecifierAST;
ast->enum_token = consumeToken();
- if (_cxx0xEnabled && (LA() == T_CLASS || LA() == T_STRUCT))
+ if (_languageFeatures.cxx11Enabled && (LA() == T_CLASS || LA() == T_STRUCT))
ast->key_token = consumeToken();
parseName(ast->name);
- if (_cxx0xEnabled && LA() == T_COLON) {
+ if (_languageFeatures.cxx11Enabled && LA() == T_COLON) {
ast->colon_token = consumeToken();
parseTypeSpecifier(ast->type_specifier_list);
}
@@ -1722,7 +1703,7 @@ bool Parser::parseEnumSpecifier(SpecifierListAST *&node)
match(T_COMMA, &comma_token);
}
match(T_RBRACE, &ast->rbrace_token);
- } else if (!_cxx0xEnabled) {
+ } else if (!_languageFeatures.cxx11Enabled) {
return false;
}
@@ -1776,7 +1757,7 @@ bool Parser::parseTypenameTypeParameter(DeclarationAST *&node)
if (LA() == T_CLASS || LA() == T_TYPENAME) {
TypenameTypeParameterAST *ast = new (_pool) TypenameTypeParameterAST;
ast->classkey_token = consumeToken();
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT)
+ if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT)
ast->dot_dot_dot_token = consumeToken();
parseName(ast->name);
if (LA() == T_EQUAL) {
@@ -1802,7 +1783,7 @@ bool Parser::parseTemplateTypeParameter(DeclarationAST *&node)
ast->greater_token = consumeToken();
if (LA() == T_CLASS)
ast->class_token = consumeToken();
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT)
+ if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT)
ast->dot_dot_dot_token = consumeToken();
// parse optional name
@@ -1943,7 +1924,7 @@ bool Parser::parseParameterDeclaration(ParameterDeclarationAST *&node)
parseDeclaratorOrAbstractDeclarator(ast->declarator, decl_specifier_seq);
if (LA() == T_EQUAL) {
ast->equal_token = consumeToken();
- if (!_cxx0xEnabled)
+ if (!_languageFeatures.cxx11Enabled)
parseLogicalOrExpression(ast->expression);
else
parseInitializerClause0x(ast->expression);
@@ -2036,7 +2017,7 @@ bool Parser::parseClassSpecifier(SpecifierListAST *&node)
parseBaseClause(base_clause_list);
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT)
+ if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT)
dot_dot_dot_token = consumeToken();
if (LA() != T_LBRACE) {
@@ -2455,7 +2436,7 @@ bool Parser::parseMemberSpecification(DeclarationAST *&node, ClassSpecifierAST *
return parseQtInterfaces(node);
case T_STATIC_ASSERT:
- if (_cxx0xEnabled)
+ if (_languageFeatures.cxx11Enabled)
return parseStaticAssertDeclaration(node);
// fall-through
@@ -2475,7 +2456,7 @@ bool Parser::parseCtorInitializer(CtorInitializerAST *&node)
parseMemInitializerList(ast->member_initializer_list);
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT)
+ if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT)
ast->dot_dot_dot_token = consumeToken();
node = ast;
@@ -2525,7 +2506,7 @@ bool Parser::parseExceptionSpecification(ExceptionSpecificationAST *&node)
ast->rparen_token = consumeToken();
node = ast;
return true;
- } else if (_cxx0xEnabled && LA() == T_NOEXCEPT) {
+ } else if (_languageFeatures.cxx11Enabled && LA() == T_NOEXCEPT) {
NoExceptSpecificationAST *ast = new (_pool) NoExceptSpecificationAST;
ast->noexcept_token = consumeToken();
if (LA() == T_LPAREN) {
@@ -2595,7 +2576,7 @@ bool Parser::parseInitDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_sp
}
rewind(colon_token);
} else if (isFunctionDeclarator && declaringClass && node->core_declarator && LA() == T_EQUAL && LA(3) == T_SEMICOLON) { // = 0, = delete, = default
- if (!_cxx0xEnabled || LA(2) == T_NUMERIC_LITERAL) {
+ if (!_languageFeatures.cxx11Enabled || LA(2) == T_NUMERIC_LITERAL) {
parseInitializer(node->initializer, &node->equal_token);
} else {
node->equal_token = consumeToken();
@@ -2607,7 +2588,7 @@ bool Parser::parseInitDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_sp
id_expr->name = simple_name;
simple_name->identifier_token = consumeToken();
}
- } else if (node->core_declarator && (LA() == T_EQUAL || (_cxx0xEnabled && !isFunctionDeclarator && LA() == T_LBRACE) || (! declaringClass && LA() == T_LPAREN))) {
+ } else if (node->core_declarator && (LA() == T_EQUAL || (_languageFeatures.cxx11Enabled && !isFunctionDeclarator && LA() == T_LBRACE) || (! declaringClass && LA() == T_LPAREN))) {
parseInitializer(node->initializer, &node->equal_token);
}
return true;
@@ -2648,7 +2629,7 @@ bool Parser::parseInitializer0x(ExpressionAST *&node, unsigned *equals_token)
{
DEBUG_THIS_RULE();
- if ((_cxx0xEnabled && LA() == T_LBRACE) || LA() == T_EQUAL) {
+ if ((_languageFeatures.cxx11Enabled && LA() == T_LBRACE) || LA() == T_EQUAL) {
if (LA() == T_EQUAL)
*equals_token = cursor();
@@ -2695,7 +2676,7 @@ bool Parser::parseInitializerList0x(ExpressionListAST *&node)
(*expression_list_ptr)->value = expression;
expression_list_ptr = &(*expression_list_ptr)->next;
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT && (LA(2) == T_COMMA || LA(2) == T_RBRACE || LA(2) == T_RPAREN))
+ if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT && (LA(2) == T_COMMA || LA(2) == T_RBRACE || LA(2) == T_RPAREN))
consumeToken(); // ### create an argument pack
while (LA() == T_COMMA && LA(2) != T_RBRACE) {
@@ -2705,7 +2686,7 @@ bool Parser::parseInitializerList0x(ExpressionListAST *&node)
*expression_list_ptr = new (_pool) ExpressionListAST;
(*expression_list_ptr)->value = expression;
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT && (LA(2) == T_COMMA || LA(2) == T_RBRACE || LA(2) == T_RPAREN))
+ if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT && (LA(2) == T_COMMA || LA(2) == T_RBRACE || LA(2) == T_RPAREN))
consumeToken(); // ### create an argument pack
expression_list_ptr = &(*expression_list_ptr)->next;
@@ -2747,12 +2728,12 @@ bool Parser::parseMemInitializerList(MemInitializerListAST *&node)
if (LA() == T_LBRACE)
break;
- else if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT && LA(2) == T_LBRACE)
+ else if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT && LA(2) == T_LBRACE)
break;
else if (LA() == T_COMMA
|| (LA() == T_IDENTIFIER
- && (LA(2) == T_LPAREN || LA(2) == T_COLON_COLON || (_cxx0xEnabled && LA(2) == T_LBRACE)))) {
+ && (LA(2) == T_LPAREN || LA(2) == T_COLON_COLON || (_languageFeatures.cxx11Enabled && LA(2) == T_LBRACE)))) {
if (LA() != T_COMMA)
error(cursor(), "expected `,'");
else
@@ -2766,7 +2747,7 @@ bool Parser::parseMemInitializerList(MemInitializerListAST *&node)
} else break;
}
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT) {
+ if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT) {
if (LA(2) != T_LBRACE)
error(cursor(), "expected `{'");
@@ -2792,10 +2773,10 @@ bool Parser::parseMemInitializer(MemInitializerListAST *&node)
if (LA() == T_LPAREN) {
parseExpressionListParen(ast->expression);
- } else if (_cxx0xEnabled && LA() == T_LBRACE) {
+ } else if (_languageFeatures.cxx11Enabled && LA() == T_LBRACE) {
parseBracedInitList0x(ast->expression);
} else {
- if (!_cxx0xEnabled)
+ if (!_languageFeatures.cxx11Enabled)
error(cursor(), "expected '('");
else
error(cursor(), "expected '(' or '{'");
@@ -2817,7 +2798,7 @@ bool Parser::parseTypeIdList(ExpressionListAST *&node)
(*expression_list_ptr)->value = typeId;
expression_list_ptr = &(*expression_list_ptr)->next;
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT)
+ if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT)
consumeToken(); // ### store this token
while (LA() == T_COMMA) {
@@ -2828,7 +2809,7 @@ bool Parser::parseTypeIdList(ExpressionListAST *&node)
(*expression_list_ptr)->value = typeId;
expression_list_ptr = &(*expression_list_ptr)->next;
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT)
+ if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT)
consumeToken(); // ### store this token
}
}
@@ -2842,7 +2823,7 @@ bool Parser::parseExpressionList(ExpressionListAST *&node)
{
DEBUG_THIS_RULE();
- if (_cxx0xEnabled)
+ if (_languageFeatures.cxx11Enabled)
return parseInitializerList0x(node);
ExpressionListAST **expression_list_ptr = &node;
@@ -2914,7 +2895,7 @@ bool Parser::parseInitializerList(ExpressionListAST *&node)
}
}
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT)
+ if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT)
consumeToken(); // ### store this token
return true;
@@ -3112,13 +3093,13 @@ bool Parser::parseStatement(StatementAST *&node)
}
case T_AT_TRY:
- return objCEnabled() && parseObjCTryStatement(node);
+ return _languageFeatures.objCEnabled && parseObjCTryStatement(node);
case T_AT_SYNCHRONIZED:
- return objCEnabled() && parseObjCSynchronizedStatement(node);
+ return _languageFeatures.objCEnabled && parseObjCSynchronizedStatement(node);
case T_AT_THROW:
- return objCEnabled() && parseObjCThrowStatement(node);
+ return _languageFeatures.objCEnabled && parseObjCThrowStatement(node);
case T_Q_D:
case T_Q_Q: {
@@ -3202,7 +3183,7 @@ bool Parser::parseReturnStatement(StatementAST *&node)
if (LA() == T_RETURN) {
ReturnStatementAST *ast = new (_pool) ReturnStatementAST;
ast->return_token = consumeToken();
- if (_cxx0xEnabled && LA() == T_LBRACE)
+ if (_languageFeatures.cxx11Enabled && LA() == T_LBRACE)
parseBracedInitList0x(ast->expression);
else
parseExpression(ast->expression);
@@ -3249,7 +3230,7 @@ bool Parser::parseExpressionOrDeclarationStatement(StatementAST *&node)
|| LA() == T_TYPENAME
|| LA() == T_ENUM
|| lookAtClassKey()
- || (LA() == T_STATIC_ASSERT && _cxx0xEnabled)) {
+ || (LA() == T_STATIC_ASSERT && _languageFeatures.cxx11Enabled)) {
return parseDeclarationStatement(node);
}
@@ -3442,7 +3423,7 @@ bool Parser::parseForStatement(StatementAST *&node)
unsigned startOfTypeSpecifier = cursor();
bool blocked = blockErrors(true);
- if (objCEnabled()) {
+ if (_languageFeatures.objCEnabled) {
ObjCFastEnumerationAST *ast = new (_pool) ObjCFastEnumerationAST;
ast->for_token = for_token;
ast->lparen_token = lparen_token;
@@ -3482,7 +3463,7 @@ bool Parser::parseForStatement(StatementAST *&node)
rewind(startOfTypeSpecifier);
}
- if (cxx0xEnabled()) {
+ if (_languageFeatures.cxx11Enabled) {
RangeBasedForStatementAST *ast = new (_pool) RangeBasedForStatementAST;
ast->for_token = for_token;
ast->lparen_token = lparen_token;
@@ -3665,7 +3646,7 @@ bool Parser::parseBlockDeclaration(DeclarationAST *&node)
return parseNamespaceAliasDefinition(node);
case T_STATIC_ASSERT:
- if (_cxx0xEnabled)
+ if (_languageFeatures.cxx11Enabled)
return parseStaticAssertDeclaration(node);
// fall-through
@@ -3746,7 +3727,7 @@ bool Parser::lookAtStorageClassSpecifier() const
case T_TYPEDEF:
return true;
case T_CONSTEXPR:
- if (_cxx0xEnabled)
+ if (_languageFeatures.cxx11Enabled)
return true;
// fall-through
default:
@@ -3944,7 +3925,7 @@ bool Parser::parseSimpleDeclaration(DeclarationAST *&node, ClassSpecifierAST *de
unsigned startOfTypeSpecifier = cursor();
if (! parseElaboratedTypeSpecifier(*decl_specifier_seq_ptr)
|| LA() == T_LBRACE
- || (_cxx0xEnabled && LA() == T_COLON)) {
+ || (_languageFeatures.cxx11Enabled && LA() == T_COLON)) {
rewind(startOfTypeSpecifier);
if (! parseEnumSpecifier(*decl_specifier_seq_ptr)) {
error(startOfTypeSpecifier,
@@ -4301,7 +4282,7 @@ bool Parser::parsePrimaryExpression(ExpressionAST *&node)
return parseStringLiteral(node);
case T_NULLPTR:
- if (_cxx0xEnabled)
+ if (_languageFeatures.cxx11Enabled)
return parsePointerLiteral(node);
// fall-through
@@ -4341,12 +4322,12 @@ bool Parser::parsePrimaryExpression(ExpressionAST *&node)
case T_LBRACKET: {
const unsigned lbracket_token = cursor();
- if (_cxx0xEnabled) {
+ if (_languageFeatures.cxx11Enabled) {
if (parseLambdaExpression(node))
return true;
}
- if (_objCEnabled) {
+ if (_languageFeatures.objCEnabled) {
rewind(lbracket_token);
return parseObjCExpression(node);
}
@@ -4828,7 +4809,7 @@ bool Parser::parseTypenameCallExpression(ExpressionAST *&node)
unsigned typename_token = consumeToken();
NameAST *name = 0;
if (parseName(name)
- && (LA() == T_LPAREN || (_cxx0xEnabled && LA() == T_LBRACE))) {
+ && (LA() == T_LPAREN || (_languageFeatures.cxx11Enabled && LA() == T_LBRACE))) {
TypenameCallExpressionAST *ast = new (_pool) TypenameCallExpressionAST;
ast->typename_token = typename_token;
ast->name = name;
@@ -4889,7 +4870,7 @@ bool Parser::parseCorePostfixExpression(ExpressionAST *&node)
bool blocked = blockErrors(true);
if (lookAtBuiltinTypeSpecifier() &&
parseSimpleTypeSpecifier(type_specifier) &&
- (LA() == T_LPAREN || (_cxx0xEnabled && LA() == T_LBRACE))) {
+ (LA() == T_LPAREN || (_languageFeatures.cxx11Enabled && LA() == T_LBRACE))) {
ExpressionAST *expr = 0;
if (LA() == T_LPAREN) {
parseExpressionListParen(expr);
@@ -4951,7 +4932,7 @@ bool Parser::parsePostfixExpression(ExpressionAST *&node)
match(T_RBRACKET, &ast->rbracket_token);
ast->base_expression = node;
node = ast;
- } else if (_cxx0xEnabled && LA() == T_LBRACE && node->asIdExpression()) {
+ } else if (_languageFeatures.cxx11Enabled && LA() == T_LBRACE && node->asIdExpression()) {
// this is slightly inconsistent: simple-type-specifier '(' expression-list ')'
// gets parsed as a CallAST while simple-type-specifier brace-init-list
// is a TypenameCallExpressionAST
@@ -5020,7 +5001,7 @@ bool Parser::parseUnaryExpression(ExpressionAST *&node)
ast->sizeof_token = consumeToken();
// sizeof...(Args)
- if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT && (LA(2) == T_IDENTIFIER || (LA(2) == T_LPAREN && LA(3) == T_IDENTIFIER
+ if (_languageFeatures.cxx11Enabled && LA() == T_DOT_DOT_DOT && (LA(2) == T_IDENTIFIER || (LA(2) == T_LPAREN && LA(3) == T_IDENTIFIER
&& LA(4) == T_RPAREN)))
ast->dot_dot_dot_token = consumeToken();
@@ -5046,7 +5027,7 @@ bool Parser::parseUnaryExpression(ExpressionAST *&node)
}
case T_ALIGNOF: {
- if (!_cxx0xEnabled)
+ if (!_languageFeatures.cxx11Enabled)
break;
AlignofExpressionAST *ast = new (_pool) AlignofExpressionAST;
@@ -5211,7 +5192,7 @@ bool Parser::parseNewInitializer(ExpressionAST *&node)
DEBUG_THIS_RULE();
if (LA() == T_LPAREN)
return parseExpressionListParen(node);
- else if (_cxx0xEnabled && LA() == T_LBRACE)
+ else if (_languageFeatures.cxx11Enabled && LA() == T_LBRACE)
return parseBracedInitList0x(node);
return false;
}
@@ -5436,7 +5417,7 @@ void Parser::parseExpressionWithOperatorPrecedence(ExpressionAST *&lhs, int minP
if (operPrecedence <= Prec::Conditional && isCPlusPlus) {
// in C++ you can put a throw in the right-most expression of a conditional expression,
// or an assignment, so some special handling:
- if (_cxx0xEnabled) {
+ if (_languageFeatures.cxx11Enabled) {
if (!parseInitializerClause0x(rhs))
return;
} else {
diff --git a/src/libs/3rdparty/cplusplus/Parser.h b/src/libs/3rdparty/cplusplus/Parser.h
index 1d505024e5..04b15b1e0d 100644
--- a/src/libs/3rdparty/cplusplus/Parser.h
+++ b/src/libs/3rdparty/cplusplus/Parser.h
@@ -36,15 +36,6 @@ public:
Parser(TranslationUnit *translationUnit);
~Parser();
- bool qtMocRunEnabled() const;
- void setQtMocRunEnabled(bool onoff);
-
- bool cxx0xEnabled() const;
- void setCxxOxEnabled(bool onoff);
-
- bool objCEnabled() const;
- void setObjCEnabled(bool onoff);
-
bool parseTranslationUnit(TranslationUnitAST *&node);
public:
@@ -315,11 +306,9 @@ private:
TranslationUnit *_translationUnit;
Control *_control;
MemoryPool *_pool;
+ LanguageFeatures _languageFeatures;
unsigned _tokenIndex;
bool _templateArguments: 1;
- bool _qtMocRunEnabled: 1;
- bool _cxx0xEnabled: 1;
- bool _objCEnabled: 1;
bool _inFunctionBody: 1;
bool _inObjCImplementationContext: 1;
bool _inExpressionStatement: 1;
diff --git a/src/libs/3rdparty/cplusplus/Token.h b/src/libs/3rdparty/cplusplus/Token.h
index 3d253151bd..6107c52538 100644
--- a/src/libs/3rdparty/cplusplus/Token.h
+++ b/src/libs/3rdparty/cplusplus/Token.h
@@ -373,6 +373,22 @@ public:
};
};
+struct LanguageFeatures
+{
+ LanguageFeatures() : flags(0) {}
+
+ union {
+ unsigned int flags;
+ struct {
+ unsigned int qtEnabled : 1; // If Qt is used.
+ unsigned int qtMocRunEnabled : 1;
+ unsigned int qtKeywordsEnabled : 1; // If Qt is used but QT_NO_KEYWORDS defined
+ unsigned int cxx11Enabled : 1;
+ unsigned int objCEnabled : 1;
+ };
+ };
+};
+
} // namespace CPlusPlus
diff --git a/src/libs/3rdparty/cplusplus/TranslationUnit.cpp b/src/libs/3rdparty/cplusplus/TranslationUnit.cpp
index 0ecb9827f8..53725dc1a0 100644
--- a/src/libs/3rdparty/cplusplus/TranslationUnit.cpp
+++ b/src/libs/3rdparty/cplusplus/TranslationUnit.cpp
@@ -63,24 +63,6 @@ TranslationUnit::~TranslationUnit()
delete _pool;
}
-bool TranslationUnit::qtMocRunEnabled() const
-{ return f._qtMocRunEnabled; }
-
-void TranslationUnit::setQtMocRunEnabled(bool onoff)
-{ f._qtMocRunEnabled = onoff; }
-
-bool TranslationUnit::cxx0xEnabled() const
-{ return f._cxx0xEnabled; }
-
-void TranslationUnit::setCxxOxEnabled(bool onoff)
-{ f._cxx0xEnabled = onoff; }
-
-bool TranslationUnit::objCEnabled() const
-{ return f._objCEnabled; }
-
-void TranslationUnit::setObjCEnabled(bool onoff)
-{ f._objCEnabled = onoff; }
-
Control *TranslationUnit::control() const
{ return _control; }
@@ -157,9 +139,7 @@ void TranslationUnit::tokenize()
f._tokenized = true;
Lexer lex(this);
- lex.setQtMocRunEnabled(f._qtMocRunEnabled);
- lex.setCxxOxEnabled(f._cxx0xEnabled);
- lex.setObjCEnabled(f._objCEnabled);
+ lex.setLanguageFeatures(_languageFeatures);
lex.setScanCommentTokens(true);
std::stack<unsigned> braces;
@@ -319,10 +299,6 @@ bool TranslationUnit::parse(ParseMode mode)
f._parsed = true;
Parser parser(this);
- parser.setQtMocRunEnabled(f._qtMocRunEnabled);
- parser.setCxxOxEnabled(f._cxx0xEnabled);
- parser.setObjCEnabled(f._objCEnabled);
-
bool parsed = false;
switch (mode) {
diff --git a/src/libs/3rdparty/cplusplus/TranslationUnit.h b/src/libs/3rdparty/cplusplus/TranslationUnit.h
index d6816b99a2..885820732e 100644
--- a/src/libs/3rdparty/cplusplus/TranslationUnit.h
+++ b/src/libs/3rdparty/cplusplus/TranslationUnit.h
@@ -87,15 +87,6 @@ public:
return previous;
}
- bool qtMocRunEnabled() const;
- void setQtMocRunEnabled(bool onoff);
-
- bool cxx0xEnabled() const;
- void setCxxOxEnabled(bool onoff);
-
- bool objCEnabled() const;
- void setObjCEnabled(bool onoff);
-
void warning(unsigned index, const char *fmt, ...);
void error(unsigned index, const char *fmt, ...);
void fatal(unsigned index, const char *fmt, ...);
@@ -151,6 +142,9 @@ public:
bool maybeSplitGreaterGreaterToken(unsigned tokenIndex);
+ LanguageFeatures languageFeatures() const { return _languageFeatures; }
+ void setLanguageFeatures(LanguageFeatures features) { _languageFeatures = features; }
+
private:
struct PPLine {
unsigned offset;
@@ -203,14 +197,12 @@ private:
unsigned _parsed: 1;
unsigned _blockErrors: 1;
unsigned _skipFunctionBody: 1;
- unsigned _qtMocRunEnabled: 1;
- unsigned _cxx0xEnabled: 1;
- unsigned _objCEnabled: 1;
};
union {
unsigned _flags;
Flags f;
};
+ LanguageFeatures _languageFeatures;
};
} // namespace CPlusPlus
diff --git a/src/libs/cplusplus/BackwardsScanner.cpp b/src/libs/cplusplus/BackwardsScanner.cpp
index 2649e13215..4d74cb3997 100644
--- a/src/libs/cplusplus/BackwardsScanner.cpp
+++ b/src/libs/cplusplus/BackwardsScanner.cpp
@@ -45,9 +45,14 @@ BackwardsScanner::BackwardsScanner(const QTextCursor &cursor,
, _block(cursor.block())
, _maxBlockCount(maxBlockCount)
{
- _tokenize.setQtMocRunEnabled(true);
+ // FIXME: Why these defaults?
+ LanguageFeatures features;
+ features.qtMocRunEnabled = true;
+ features.qtEnabled = true;
+ features.qtKeywordsEnabled = true;
+ features.objCEnabled = true;
+ _tokenize.setLanguageFeatures(features);
_tokenize.setSkipComments(skipComments);
- _tokenize.setObjCEnabled(true);
_text = _block.text().left(cursor.position() - cursor.block().position());
if (! suffix.isEmpty())
diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp
index 0d8bbd2f31..46fee7f443 100644
--- a/src/libs/cplusplus/CppDocument.cpp
+++ b/src/libs/cplusplus/CppDocument.cpp
@@ -284,10 +284,14 @@ Document::Document(const QString &fileName)
const QByteArray localFileName = fileName.toUtf8();
const StringLiteral *fileId = _control->stringLiteral(localFileName.constData(),
localFileName.size());
+ LanguageFeatures features;
+ features.qtEnabled = true;
+ features.qtMocRunEnabled = true;
+ features.qtKeywordsEnabled = true;
+ features.cxx11Enabled = true;
+ features.objCEnabled = true;
_translationUnit = new TranslationUnit(_control, fileId);
- _translationUnit->setQtMocRunEnabled(true);
- _translationUnit->setCxxOxEnabled(true);
- _translationUnit->setObjCEnabled(true);
+ _translationUnit->setLanguageFeatures(features);
(void) _control->switchTranslationUnit(_translationUnit);
}
diff --git a/src/libs/cplusplus/SimpleLexer.cpp b/src/libs/cplusplus/SimpleLexer.cpp
index 243dd7e91c..fc6f346076 100644
--- a/src/libs/cplusplus/SimpleLexer.cpp
+++ b/src/libs/cplusplus/SimpleLexer.cpp
@@ -40,46 +40,12 @@ using namespace CPlusPlus;
SimpleLexer::SimpleLexer()
: _lastState(0),
_skipComments(false),
- _qtMocRunEnabled(true),
- _objCEnabled(false),
- _endedJoined(false),
- _cxx0xEnabled(false)
-{
-}
+ _endedJoined(false)
+{}
SimpleLexer::~SimpleLexer()
{ }
-bool SimpleLexer::qtMocRunEnabled() const
-{
- return _qtMocRunEnabled;
-}
-
-void SimpleLexer::setQtMocRunEnabled(bool enabled)
-{
- _qtMocRunEnabled = enabled;
-}
-
-bool SimpleLexer::objCEnabled() const
-{
- return _objCEnabled;
-}
-
-void SimpleLexer::setObjCEnabled(bool onoff)
-{
- _objCEnabled = onoff;
-}
-
-bool SimpleLexer::cxx0xEnabled() const
-{
- return _cxx0xEnabled;
-}
-
-void SimpleLexer::setCxx0xEnabled(bool enabled)
-{
- _cxx0xEnabled = enabled;
-}
-
bool SimpleLexer::skipComments() const
{
return _skipComments;
@@ -104,11 +70,8 @@ QList<Token> SimpleLexer::operator()(const QString &text, int state)
const char *lastChar = firstChar + bytes.size();
Lexer lex(firstChar, lastChar);
- lex.setQtMocRunEnabled(_qtMocRunEnabled);
- lex.setObjCEnabled(_objCEnabled);
+ lex.setLanguageFeatures(_languageFeatures);
lex.setStartWithNewline(true);
- lex.setObjCEnabled(_objCEnabled);
- lex.setCxxOxEnabled(_cxx0xEnabled);
if (! _skipComments)
lex.setScanCommentTokens(true);
@@ -137,7 +100,7 @@ QList<Token> SimpleLexer::operator()(const QString &text, int state)
else if (inPreproc && tokens.size() == 1 && tk.is(T_IDENTIFIER) &&
spell == QLatin1String("include_next"))
lex.setScanAngleStringLiteralTokens(true);
- else if (_objCEnabled
+ else if (_languageFeatures.objCEnabled
&& inPreproc && tokens.size() == 1 && tk.is(T_IDENTIFIER) &&
spell == QLatin1String("import"))
lex.setScanAngleStringLiteralTokens(true);
@@ -165,8 +128,13 @@ Token SimpleLexer::tokenAt(const QString &text,
int state,
bool qtMocRunEnabled)
{
+ // FIXME: Check default values.
+ LanguageFeatures features;
+ features.qtMocRunEnabled = qtMocRunEnabled;
+ features.qtEnabled = qtMocRunEnabled;
+ features.qtKeywordsEnabled = qtMocRunEnabled;
SimpleLexer tokenize;
- tokenize.setQtMocRunEnabled(qtMocRunEnabled);
+ tokenize.setLanguageFeatures(features);
const QList<Token> tokens = tokenize(text, state);
const int tokenIdx = tokenAt(tokens, offset);
return (tokenIdx == -1) ? Token() : tokens.at(tokenIdx);
diff --git a/src/libs/cplusplus/SimpleLexer.h b/src/libs/cplusplus/SimpleLexer.h
index dac658f01f..a730b2d42a 100644
--- a/src/libs/cplusplus/SimpleLexer.h
+++ b/src/libs/cplusplus/SimpleLexer.h
@@ -30,6 +30,7 @@
#define CPLUSPLUS_SIMPLELEXER_H
#include <cplusplus/CPlusPlusForwardDeclarations.h>
+#include <cplusplus/Token.h>
#include <QString>
#include <QList>
@@ -48,14 +49,8 @@ public:
bool skipComments() const;
void setSkipComments(bool skipComments);
- bool qtMocRunEnabled() const;
- void setQtMocRunEnabled(bool enabled);
-
- bool objCEnabled() const;
- void setObjCEnabled(bool onoff);
-
- bool cxx0xEnabled() const;
- void setCxx0xEnabled(bool enabled);
+ LanguageFeatures languageFeatures() const { return _languageFeatures; }
+ void setLanguageFeatures(LanguageFeatures features) { _languageFeatures = features; }
bool endedJoined() const;
@@ -74,11 +69,9 @@ public:
private:
int _lastState;
+ LanguageFeatures _languageFeatures;
bool _skipComments: 1;
- bool _qtMocRunEnabled: 1;
- bool _objCEnabled: 1;
bool _endedJoined: 1;
- bool _cxx0xEnabled: 1;
};
} // namespace CPlusPlus
diff --git a/src/plugins/cppeditor/cppautocompleter.cpp b/src/plugins/cppeditor/cppautocompleter.cpp
index f7e9233bb2..451ad70fe4 100644
--- a/src/plugins/cppeditor/cppautocompleter.cpp
+++ b/src/plugins/cppeditor/cppautocompleter.cpp
@@ -101,10 +101,14 @@ QString CppAutoCompleter::insertParagraphSeparator(const QTextCursor &cursor) co
bool CppAutoCompleter::isInCommentHelper(const QTextCursor &cursor, Token *retToken) const
{
+ LanguageFeatures features;
+ features.qtEnabled = false;
+ features.qtKeywordsEnabled = false;
+ features.qtMocRunEnabled = false;
+ features.cxx11Enabled = true;
+
SimpleLexer tokenize;
- tokenize.setQtMocRunEnabled(false);
- tokenize.setObjCEnabled(false);
- tokenize.setCxx0xEnabled(true);
+ tokenize.setLanguageFeatures(features);
const int prevState = BackwardsScanner::previousBlockState(cursor.block()) & 0xFF;
const QList<Token> tokens = tokenize(cursor.block().text(), prevState);
diff --git a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp
index 026b5c2e45..bd2acf05ab 100644
--- a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp
+++ b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp
@@ -327,8 +327,13 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &
int beginOfToken = 0;
int endOfToken = 0;
+ LanguageFeatures features;
+ features.qtEnabled = true;
+ features.qtKeywordsEnabled = true;
+ features.qtMocRunEnabled = true;
+
SimpleLexer tokenize;
- tokenize.setQtMocRunEnabled(true);
+ tokenize.setLanguageFeatures(features);
const QString blockText = cursor.block().text();
const QList<Token> tokens = tokenize(blockText,
BackwardsScanner::previousBlockState(cursor.block()));
diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp
index 7e16616ed2..ec143ee6d0 100644
--- a/src/plugins/cppeditor/cpphighlighter.cpp
+++ b/src/plugins/cppeditor/cpphighlighter.cpp
@@ -74,10 +74,12 @@ void CppHighlighter::highlightBlock(const QString &text)
int braceDepth = initialBraceDepth;
+ // FIXME: Check defaults or get from document.
+ LanguageFeatures features;
+ features.cxx11Enabled = true;
+
SimpleLexer tokenize;
- tokenize.setQtMocRunEnabled(false);
- tokenize.setObjCEnabled(false);
- tokenize.setCxx0xEnabled(true);
+ tokenize.setLanguageFeatures(features);
int initialState = state;
const QList<Token> tokens = tokenize(text, initialState);
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp
index 72e0edb76f..d83434fde9 100644
--- a/src/plugins/cpptools/cppcodeformatter.cpp
+++ b/src/plugins/cpptools/cppcodeformatter.cpp
@@ -1055,9 +1055,14 @@ int CodeFormatter::tokenizeBlock(const QTextBlock &block, bool *endedJoined)
startState = 0;
QTC_ASSERT(startState != -1, return 0);
+ LanguageFeatures features;
+ features.qtEnabled = true;
+ features.qtMocRunEnabled = true;
+ features.qtKeywordsEnabled = true;
+ features.objCEnabled = true;
+
SimpleLexer tokenize;
- tokenize.setQtMocRunEnabled(true);
- tokenize.setObjCEnabled(true);
+ tokenize.setLanguageFeatures(features);
m_currentLine = block.text();
// to determine whether a line was joined, Tokenizer needs a
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp
index 59d2b8aa53..4624fb6fbd 100644
--- a/src/plugins/cpptools/cppcompletionassist.cpp
+++ b/src/plugins/cpptools/cppcompletionassist.cpp
@@ -616,7 +616,6 @@ bool isQPrivateSignal(const Symbol *symbol)
// ----------------------------
CppCompletionAssistProcessor::CppCompletionAssistProcessor()
: m_startPosition(-1)
- , m_objcEnabled(true)
, m_snippetCollector(QLatin1String(CppEditor::Constants::CPP_SNIPPETS_GROUP_ID),
QIcon(QLatin1String(":/texteditor/images/snippet.png")))
, preprocessorCompletions(QStringList()
@@ -634,7 +633,13 @@ CppCompletionAssistProcessor::CppCompletionAssistProcessor()
<< QLatin1String("endif"))
, m_model(new CppAssistProposalModel)
, m_hintProposal(0)
-{}
+{
+ // FIXME: C++11?
+ m_languageFeatures.objCEnabled = true;
+ m_languageFeatures.qtEnabled = true;
+ m_languageFeatures.qtKeywordsEnabled = true;
+ m_languageFeatures.qtMocRunEnabled = true;
+}
CppCompletionAssistProcessor::~CppCompletionAssistProcessor()
{}
@@ -683,10 +688,16 @@ bool CppCompletionAssistProcessor::accepts() const
QTextCursor tc(m_interface->textDocument());
tc.setPosition(pos);
+ LanguageFeatures features;
+ features.qtEnabled = true;
+ features.qtMocRunEnabled = true;
+ features.qtKeywordsEnabled = true;
+ features.objCEnabled = true;
+
SimpleLexer tokenize;
- tokenize.setQtMocRunEnabled(true);
- tokenize.setObjCEnabled(true);
+ tokenize.setLanguageFeatures(features);
tokenize.setSkipComments(false);
+
const QList<Token> &tokens = tokenize(tc.block().text(), BackwardsScanner::previousBlockState(tc.block()));
const int tokenIdx = SimpleLexer::tokenBefore(tokens, qMax(0, tc.positionInBlock() - 1));
const Token tk = (tokenIdx == -1) ? Token() : tokens.at(tokenIdx);
@@ -703,7 +714,7 @@ bool CppCompletionAssistProcessor::accepts() const
line.midRef(idToken.begin(), idToken.end() - idToken.begin());
if (identifier == QLatin1String("include")
|| identifier == QLatin1String("include_next")
- || (m_objcEnabled && identifier == QLatin1String("import"))) {
+ || (m_languageFeatures.objCEnabled && identifier == QLatin1String("import"))) {
return true;
}
}
@@ -787,8 +798,7 @@ int CppCompletionAssistProcessor::startOfOperator(int pos,
}
SimpleLexer tokenize;
- tokenize.setQtMocRunEnabled(true);
- tokenize.setObjCEnabled(true);
+ tokenize.setLanguageFeatures(m_languageFeatures);
tokenize.setSkipComments(false);
const QList<Token> &tokens = tokenize(tc.block().text(), BackwardsScanner::previousBlockState(tc.block()));
const int tokenIdx = SimpleLexer::tokenBefore(tokens, qMax(0, tc.positionInBlock() - 1)); // get the token at the left of the cursor
@@ -879,7 +889,7 @@ int CppCompletionAssistProcessor::findStartOfName(int pos) const
int CppCompletionAssistProcessor::startCompletionHelper()
{
- if (m_objcEnabled) {
+ if (m_languageFeatures.objCEnabled) {
if (tryObjCCompletion())
return m_startPosition;
}
@@ -1193,7 +1203,7 @@ void CppCompletionAssistProcessor::completePreprocessor()
bool CppCompletionAssistProcessor::objcKeywordsWanted() const
{
- if (!m_objcEnabled)
+ if (!m_languageFeatures.objCEnabled)
return false;
const QString fileName = m_interface->fileName();
diff --git a/src/plugins/cpptools/cppcompletionassist.h b/src/plugins/cpptools/cppcompletionassist.h
index 6345d895b2..454e737d4a 100644
--- a/src/plugins/cpptools/cppcompletionassist.h
+++ b/src/plugins/cpptools/cppcompletionassist.h
@@ -152,7 +152,7 @@ private:
QSet<QString> *definedMacros);
int m_startPosition;
- bool m_objcEnabled;
+ CPlusPlus::LanguageFeatures m_languageFeatures;
QScopedPointer<const CppCompletionAssistInterface> m_interface;
QList<TextEditor::BasicProposalItem *> m_completions;
TextEditor::SnippetAssistCollector m_snippetCollector;
diff --git a/src/plugins/cpptools/cpphighlightingsupportinternal.cpp b/src/plugins/cpptools/cpphighlightingsupportinternal.cpp
index 4ad285258b..3009d45c16 100644
--- a/src/plugins/cpptools/cpphighlightingsupportinternal.cpp
+++ b/src/plugins/cpptools/cpphighlightingsupportinternal.cpp
@@ -73,11 +73,14 @@ QFuture<TextEditor::HighlightingResult> CppHighlightingSupportInternal::highligh
if (isQtKeyword(QStringRef(&name)))
continue;
- //Filter out C++ keywords
+ // Filter out C++ keywords
+ // FIXME: Check default values or get from document.
+ LanguageFeatures features;
+ features.cxx11Enabled = true;
+
SimpleLexer tokenize;
- tokenize.setQtMocRunEnabled(false);
- tokenize.setObjCEnabled(false);
- tokenize.setCxx0xEnabled(true);
+ tokenize.setLanguageFeatures(features);
+
const QList<Token> tokens = tokenize(name);
if (tokens.length() && (tokens.at(0).isKeyword() || tokens.at(0).isObjCAtKeyword()))
continue;
diff --git a/tests/auto/cplusplus/ast/tst_ast.cpp b/tests/auto/cplusplus/ast/tst_ast.cpp
index 329662892e..968d80e110 100644
--- a/tests/auto/cplusplus/ast/tst_ast.cpp
+++ b/tests/auto/cplusplus/ast/tst_ast.cpp
@@ -45,16 +45,19 @@ class tst_AST: public QObject
Control control;
public:
-
TranslationUnit *parse(const QByteArray &source,
TranslationUnit::ParseMode mode,
bool blockErrors = false,
bool qtMocRun = false)
{
const StringLiteral *fileId = control.stringLiteral("<stdin>");
+ LanguageFeatures features;
+ features.objCEnabled = true;
+ features.qtEnabled = qtMocRun;
+ features.qtKeywordsEnabled = qtMocRun;
+ features.qtMocRunEnabled = qtMocRun;
TranslationUnit *unit = new TranslationUnit(&control, fileId);
- unit->setObjCEnabled(true);
- unit->setQtMocRunEnabled(qtMocRun);
+ unit->setLanguageFeatures(features);
unit->setSource(source.constData(), source.length());
unit->blockErrors(blockErrors);
unit->parse(mode);
diff --git a/tests/auto/cplusplus/cxx11/tst_cxx11.cpp b/tests/auto/cplusplus/cxx11/tst_cxx11.cpp
index c5cfa25eb4..8ac002e376 100644
--- a/tests/auto/cplusplus/cxx11/tst_cxx11.cpp
+++ b/tests/auto/cplusplus/cxx11/tst_cxx11.cpp
@@ -103,10 +103,12 @@ class tst_cxx11: public QObject
Document::Ptr doc = Document::create(fileName);
QFile file(testdata(fileName));
if (file.open(QFile::ReadOnly)) {
+ LanguageFeatures features;
+ features.cxx11Enabled = true;
Client client(errors);
doc->control()->setDiagnosticClient(&client);
doc->setUtf8Source(QTextStream(&file).readAll().toUtf8());
- doc->translationUnit()->setCxxOxEnabled(true);
+ doc->translationUnit()->setLanguageFeatures(features);
doc->check();
doc->control()->setDiagnosticClient(0);
} else {
diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp
index db9e8cd949..bfeb09dd1b 100644
--- a/tests/auto/cplusplus/semantic/tst_semantic.cpp
+++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp
@@ -67,16 +67,12 @@ public:
TranslationUnit *parse(const QByteArray &source,
TranslationUnit::ParseMode mode,
- bool enableObjc,
- bool qtMocRun,
- bool enableCxx11)
+ LanguageFeatures features)
{
const StringLiteral *fileId = control->stringLiteral("<stdin>");
TranslationUnit *unit = new TranslationUnit(control.data(), fileId);
unit->setSource(source.constData(), source.length());
- unit->setObjCEnabled(enableObjc);
- unit->setQtMocRunEnabled(qtMocRun);
- unit->setCxxOxEnabled(enableCxx11);
+ unit->setLanguageFeatures(features);
unit->parse(mode);
return unit;
}
@@ -141,8 +137,14 @@ public:
QSharedPointer<Document> document(const QByteArray &source, bool enableObjc = false, bool qtMocRun = false, bool enableCxx11 = false)
{
+ LanguageFeatures features;
+ features.objCEnabled = enableObjc;
+ features.qtEnabled = qtMocRun;
+ features.qtMocRunEnabled = qtMocRun;
+ features.qtKeywordsEnabled = qtMocRun;
+ features.cxx11Enabled = enableCxx11;
diag.errorCount = 0; // reset the error count.
- TranslationUnit *unit = parse(source, TranslationUnit::ParseTranlationUnit, enableObjc, qtMocRun, enableCxx11);
+ TranslationUnit *unit = parse(source, TranslationUnit::ParseTranlationUnit, features);
QSharedPointer<Document> doc(new Document(unit));
doc->check();
doc->errorCount = diag.errorCount;