@@ -67,6 +67,62 @@ CXXToken * cxxParserFindFirstPossiblyNestedAndQualifiedIdentifier(
67
67
return cxxTokenChainNextTokenOfType (pId ,CXXTokenTypeIdentifier );
68
68
}
69
69
70
+ static void cxxParserExtractMembersInitialization (CXXTokenChain * pChain , int iScopeCorkIndex )
71
+ {
72
+ tagEntryInfo * pTag = getEntryInCorkQueue (iScopeCorkIndex );
73
+ if (!pTag || pTag -> kindIndex != CXXTagKindVARIABLE )
74
+ return ;
75
+
76
+ // Looking for the pattern:
77
+ //
78
+ // { .member = ...
79
+ //
80
+ // or
81
+ //
82
+ // ; .member = ...
83
+ //
84
+ for (CXXToken * t = cxxTokenChainFirst (pChain ); t && t != pChain -> pTail ; t = t -> pNext )
85
+ {
86
+ if (
87
+ (cxxTokenTypeIs (t , CXXTokenTypeOpeningBracket )
88
+ || cxxTokenTypeIs (t , CXXTokenTypeComma )) &&
89
+ (t -> pNext
90
+ && cxxTokenTypeIs (t -> pNext , CXXTokenTypeDotOperator )) &&
91
+ (t -> pNext -> pNext
92
+ && cxxTokenTypeIs (t -> pNext -> pNext , CXXTokenTypeIdentifier )) &&
93
+ (t -> pNext -> pNext -> pNext
94
+ && cxxTokenTypeIs (t -> pNext -> pNext -> pNext , CXXTokenTypeAssignment ))
95
+ )
96
+ {
97
+ CXXToken * pIdentifier = t -> pNext -> pNext ;
98
+ if (pIdentifier -> iCorkIndex != CORK_NIL && pIdentifier -> bCorkIndexForReftag )
99
+ {
100
+ // Tagged with "unknown" kind already. Reset it.
101
+ cxxTagResetRefTag (pIdentifier -> iCorkIndex , iScopeCorkIndex ,
102
+ CXXTagKindMEMBER , CXXTagMemberRoleINITIALIZED );
103
+ }
104
+ else if (pIdentifier -> iCorkIndex == CORK_NIL )
105
+ {
106
+ tagEntryInfo oEntry ;
107
+ initRefTagEntry (& oEntry , vStringValue (t -> pszWord ),
108
+ CXXTagKindMEMBER , CXXTagMemberRoleINITIALIZED );
109
+ oEntry .lineNumber = t -> iLineNumber ;
110
+ oEntry .filePosition = t -> oFilePosition ;
111
+ oEntry .isFileScope = false;
112
+ // TODO: Other scope field must be filled.
113
+ oEntry .extensionFields .scopeIndex = iScopeCorkIndex ;
114
+ pIdentifier -> iCorkIndex = makeTagEntry (& oEntry );
115
+ registerEntry (pIdentifier -> iCorkIndex );
116
+ pIdentifier -> bCorkIndexForReftag = 1 ;
117
+
118
+ }
119
+ // Point t to the assignment.
120
+ t = t -> pNext -> pNext -> pNext ;
121
+ }
122
+ }
123
+ return ;
124
+ }
125
+
70
126
//
71
127
// Attempt to extract variable declarations from the chain.
72
128
// Returns true if at least one variable was extracted.
@@ -800,11 +856,18 @@ bool cxxParserExtractVariableDeclarations(CXXTokenChain * pChain,unsigned int uF
800
856
return bGotVariable ;
801
857
}
802
858
859
+ // pointing {} of ... = {}
860
+ CXXToken * pTokenBracketChain = NULL ;
803
861
if (!cxxTokenTypeIsOneOf (
804
862
t ,
805
863
CXXTokenTypeComma | CXXTokenTypeSemicolon | CXXTokenTypeOpeningBracket
806
864
))
807
865
{
866
+ if (iCorkIndex != CORK_NIL &&
867
+ cxxTokenTypeIs (t , CXXTokenTypeAssignment ) &&
868
+ t -> pNext && cxxTokenTypeIs (t -> pNext , CXXTokenTypeBracketChain ) &&
869
+ t -> pNext -> pChain )
870
+ pTokenBracketChain = t -> pNext ;
808
871
// look for it, but also check for "<" signs: these usually indicate an uncondensed
809
872
// template. We give up on them as they are too complicated in this context.
810
873
// It's rather unlikely to have multiple declarations with templates after the first one
@@ -829,6 +892,9 @@ bool cxxParserExtractVariableDeclarations(CXXTokenChain * pChain,unsigned int uF
829
892
{
830
893
if (iCorkIndex != CORK_NIL )
831
894
{
895
+ if (pTokenBracketChain )
896
+ cxxParserExtractMembersInitialization (pTokenBracketChain -> pChain ,
897
+ iCorkIndex );
832
898
cxxParserSetEndLineForTagInCorkQueue (iCorkIndex , t -> iLineNumber );
833
899
iCorkIndex = CORK_NIL ;
834
900
if (iCorkIndexFQ != CORK_NIL )
@@ -844,6 +910,9 @@ bool cxxParserExtractVariableDeclarations(CXXTokenChain * pChain,unsigned int uF
844
910
// Comma. Might have other declarations here.
845
911
if (iCorkIndex != CORK_NIL )
846
912
{
913
+ if (pTokenBracketChain )
914
+ cxxParserExtractMembersInitialization (pTokenBracketChain -> pChain ,
915
+ iCorkIndex );
847
916
cxxParserSetEndLineForTagInCorkQueue (iCorkIndex , t -> iLineNumber );
848
917
iCorkIndex = CORK_NIL ;
849
918
if (iCorkIndexFQ != CORK_NIL )
0 commit comments