From eac518aee6ea7173e5462fe16768ebb1b3f54b29 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sun, 24 Nov 2013 18:25:32 +0200 Subject: C++: Support __thread and thread_local Task-number: QTCREATORBUG-7679 Change-Id: I794f52b2bcfb6c78ceef86ec53b6ed32b3d53d9f Reviewed-by: Orgad Shaneh Reviewed-by: Erik Verbruggen --- src/libs/3rdparty/cplusplus/Keywords.cpp | 36 ++++++++++++++++++++++++++++++++ src/libs/3rdparty/cplusplus/Parser.cpp | 3 +++ src/libs/3rdparty/cplusplus/Token.cpp | 4 ++-- src/libs/3rdparty/cplusplus/Token.h | 2 ++ 4 files changed, 43 insertions(+), 2 deletions(-) (limited to 'src/libs/3rdparty/cplusplus') diff --git a/src/libs/3rdparty/cplusplus/Keywords.cpp b/src/libs/3rdparty/cplusplus/Keywords.cpp index 91c9ffc312..9bce1ff3f8 100644 --- a/src/libs/3rdparty/cplusplus/Keywords.cpp +++ b/src/libs/3rdparty/cplusplus/Keywords.cpp @@ -803,6 +803,17 @@ static inline int classify8(const char *s, LanguageFeatures features) } } } + else if (s[3] == 'h') { + if (s[4] == 'r') { + if (s[5] == 'e') { + if (s[6] == 'a') { + if (s[7] == 'd') { + return T___THREAD; + } + } + } + } + } } } } @@ -1443,6 +1454,31 @@ static inline int classify12(const char *s, LanguageFeatures features) } } } + else if (features.cxx11Enabled && s[0] == 't') { + if (s[1] == 'h') { + if (s[2] == 'r') { + if (s[3] == 'e') { + if (s[4] == 'a') { + if (s[5] == 'd') { + if (s[6] == '_') { + if (s[7] == 'l') { + if (s[8] == 'o') { + if (s[9] == 'c') { + if (s[10] == 'a') { + if (s[11] == 'l') { + return T_THREAD_LOCAL; + } + } + } + } + } + } + } + } + } + } + } + } return T_IDENTIFIER; } diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp index 51e78abe5c..467bf6e694 100644 --- a/src/libs/3rdparty/cplusplus/Parser.cpp +++ b/src/libs/3rdparty/cplusplus/Parser.cpp @@ -3725,7 +3725,10 @@ bool Parser::lookAtStorageClassSpecifier() const case T_EXTERN: case T_MUTABLE: case T_TYPEDEF: + case T___THREAD: return true; + case T_THREAD_LOCAL: + return _languageFeatures.cxx11Enabled; case T_CONSTEXPR: if (_languageFeatures.cxx11Enabled) return true; diff --git a/src/libs/3rdparty/cplusplus/Token.cpp b/src/libs/3rdparty/cplusplus/Token.cpp index ab6d3c0317..1469edea7f 100644 --- a/src/libs/3rdparty/cplusplus/Token.cpp +++ b/src/libs/3rdparty/cplusplus/Token.cpp @@ -57,13 +57,13 @@ const char *token_names[] = { ("nullptr"), ("operator"), ("private"), ("protected"), ("public"), ("register"), ("reinterpret_cast"), ("return"), ("short"), ("signed"), ("sizeof"), ("static"),("static_assert"), - ("static_cast"), ("struct"), ("switch"), ("template"), ("this"), + ("static_cast"), ("struct"), ("switch"), ("template"), ("this"), ("thread_local"), ("throw"), ("true"), ("try"), ("typedef"), ("typeid"), ("typename"), ("union"), ("unsigned"), ("using"), ("virtual"), ("void"), ("volatile"), ("wchar_t"), ("while"), // gnu - ("__attribute__"), ("__typeof__"), + ("__attribute__"), ("__thread"), ("__typeof__"), // objc @keywords ("@catch"), ("@class"), ("@compatibility_alias"), ("@defs"), ("@dynamic"), diff --git a/src/libs/3rdparty/cplusplus/Token.h b/src/libs/3rdparty/cplusplus/Token.h index 6107c52538..58fcee3a48 100644 --- a/src/libs/3rdparty/cplusplus/Token.h +++ b/src/libs/3rdparty/cplusplus/Token.h @@ -173,6 +173,7 @@ enum Kind { T_SWITCH, T_TEMPLATE, T_THIS, + T_THREAD_LOCAL, T_THROW, T_TRUE, T_TRY, @@ -189,6 +190,7 @@ enum Kind { T_WHILE, T___ATTRIBUTE__, + T___THREAD, T___TYPEOF__, // obj c++ @ keywords -- cgit v1.2.1 From 5c5240815a9577fdb2e5b5ed90fa64f9b57fee44 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 26 Nov 2013 15:23:28 +0100 Subject: CPlusPlus: Fix parsing of ??< ??> ??( ??) trigraphs Almost most useful feature ever. Task-number: QTCREATORBUG-2474 Change-Id: If1ad661fab58ffb4a0b9ddb8ba771f2fde3b54ec Reviewed-by: Nikolai Kosjar --- src/libs/3rdparty/cplusplus/Lexer.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/libs/3rdparty/cplusplus') diff --git a/src/libs/3rdparty/cplusplus/Lexer.cpp b/src/libs/3rdparty/cplusplus/Lexer.cpp index 6e6e6c2feb..0e0d1f4330 100644 --- a/src/libs/3rdparty/cplusplus/Lexer.cpp +++ b/src/libs/3rdparty/cplusplus/Lexer.cpp @@ -297,7 +297,24 @@ void Lexer::scan_helper(Token *tok) break; case '?': - tok->f.kind = T_QUESTION; + if (_yychar == '?') { + yyinp(); + if (_yychar == '(') { + yyinp(); + tok->f.kind = T_LBRACKET; + } else if (_yychar == ')') { + yyinp(); + tok->f.kind = T_RBRACKET; + } else if (_yychar == '<') { + yyinp(); + tok->f.kind = T_LBRACE; + } else if (_yychar == '>') { + yyinp(); + tok->f.kind = T_RBRACE; + } + } else { + tok->f.kind = T_QUESTION; + } break; case '+': -- cgit v1.2.1