Skip to content

Commit 29bcaad

Browse files
committed
C++: add "thread_local" to "properties:" field instead of recording the keyword as a part of typeref
Signed-off-by: Masatake YAMATO <[email protected]>
1 parent f616464 commit 29bcaad

File tree

7 files changed

+14
-2
lines changed

7 files changed

+14
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
g input.cc /^const char *g() { return "dynamic initialization"; }$/;" f typeref:typename:const char *
22
f input.cc /^constexpr const char *f(bool p) { return p ? "constant initializer" : g(); }$/;" f typeref:typename:const char * properties:constexpr
33
c input.cc /^constinit const char *c = f(true); \/\/ OK$/;" v typeref:typename:const char * properties:constinit
4-
x input.cc /^extern thread_local constinit int x;$/;" x typeref:typename:thread_local int properties:extern,constinit
4+
x input.cc /^extern thread_local constinit int x;$/;" x typeref:typename:int properties:extern,constinit,thread_local
55
f input.cc /^int f() { return x; } \/\/ no check of a guard variable needed$/;" f typeref:typename:int

parsers/cxx/cxx_keyword.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ static CXXKeywordDescriptor g_aCXXKeywordTable[] = {
475475
{
476476
"thread_local",
477477
CXXLanguageCPP,
478-
CXXKeywordMayAppearInVariableDeclaration
478+
CXXKeywordMayAppearInVariableDeclaration | CXXKeywordExcludeFromTypeNames
479479
},
480480
{
481481
"throw",

parsers/cxx/cxx_parser_block.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,10 @@ static bool cxxParserParseBlockInternal(bool bExpectClosingBracket)
646646
case CXXKeywordCONSTINIT:
647647
g_cxx.uKeywordState |= CXXParserKeywordStateSeenConstinit;
648648
break;
649+
case CXXKeywordTHREAD_LOCAL:
650+
g_cxx.uKeywordState |= CXXParserKeywordStateSeenThreadLocal;
651+
break;
652+
649653
default:
650654
if(g_cxx.uKeywordState & CXXParserKeywordStateSeenTypedef)
651655
{

parsers/cxx/cxx_parser_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ typedef enum _CXXParserKeywordState
290290
CXXParserKeywordStateSeenConsteval = (1 << 14),
291291
// "constinit" has been seen
292292
CXXParserKeywordStateSeenConstinit = (1 << 15),
293+
// "thread_local" has been seen
294+
CXXParserKeywordStateSeenThreadLocal = (1 << 16),
293295
} CXXParserKeywordState;
294296

295297
#define CXX_PARSER_MAXIMUM_NESTING_LEVELS 1024

parsers/cxx/cxx_parser_variable.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ bool cxxParserExtractVariableDeclarations(CXXTokenChain * pChain,unsigned int uF
762762
if(g_cxx.uKeywordState & CXXParserKeywordStateSeenConstinit)
763763
uProperties |= CXXTagPropertyConstinit;
764764
// consteval is not here; it is for functions.
765+
if(g_cxx.uKeywordState & CXXParserKeywordStateSeenThreadLocal)
766+
uProperties |= CXXTagPropertyThreadLocal;
765767

766768
pszProperties = cxxTagSetProperties(uProperties);
767769
}

parsers/cxx/cxx_tag.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ vString * cxxTagSetProperties(unsigned int uProperties)
376376
ADD_PROPERTY("consteval");
377377
if (uProperties & CXXTagPropertyConstinit)
378378
ADD_PROPERTY("constinit");
379+
if (uProperties & CXXTagPropertyThreadLocal)
380+
ADD_PROPERTY("thread_local");
379381

380382
cxxTagSetField(CXXTagFieldProperties,vStringValue(pszProperties),false);
381383

parsers/cxx/cxx_tag.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ typedef enum _CXXTagProperty
157157
CXXTagPropertyConsteval = (1 << 19),
158158
// constinit has been seen.
159159
CXXTagPropertyConstinit = (1 << 20),
160+
// thread_local has been seen.
161+
CXXTagPropertyThreadLocal = (1 << 21),
160162
} CXXTagProperty;
161163

162164
// Set the modifiers field of the tag.

0 commit comments

Comments
 (0)