@@ -67,6 +67,62 @@ CXXToken * cxxParserFindFirstPossiblyNestedAndQualifiedIdentifier(
6767 return cxxTokenChainNextTokenOfType (pId ,CXXTokenTypeIdentifier );
6868}
6969
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 (pIdentifier -> pszWord ),
108+ CXXTagKindMEMBER , CXXTagMemberRoleINITIALIZED );
109+ oEntry .lineNumber = pIdentifier -> iLineNumber ;
110+ oEntry .filePosition = pIdentifier -> 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+
70126//
71127// Attempt to extract variable declarations from the chain.
72128// Returns true if at least one variable was extracted.
@@ -800,11 +856,18 @@ bool cxxParserExtractVariableDeclarations(CXXTokenChain * pChain,unsigned int uF
800856 return bGotVariable ;
801857 }
802858
859+ // pointing {} of ... = {}
860+ CXXToken * pTokenBracketChain = NULL ;
803861 if (!cxxTokenTypeIsOneOf (
804862 t ,
805863 CXXTokenTypeComma | CXXTokenTypeSemicolon | CXXTokenTypeOpeningBracket
806864 ))
807865 {
866+ if (iCorkIndex != CORK_NIL &&
867+ cxxTokenTypeIs (t , CXXTokenTypeAssignment ) &&
868+ t -> pNext && cxxTokenTypeIs (t -> pNext , CXXTokenTypeBracketChain ) &&
869+ t -> pNext -> pChain )
870+ pTokenBracketChain = t -> pNext ;
808871 // look for it, but also check for "<" signs: these usually indicate an uncondensed
809872 // template. We give up on them as they are too complicated in this context.
810873 // 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
829892 {
830893 if (iCorkIndex != CORK_NIL )
831894 {
895+ if (pTokenBracketChain )
896+ cxxParserExtractMembersInitialization (pTokenBracketChain -> pChain ,
897+ iCorkIndex );
832898 cxxParserSetEndLineForTagInCorkQueue (iCorkIndex , t -> iLineNumber );
833899 iCorkIndex = CORK_NIL ;
834900 if (iCorkIndexFQ != CORK_NIL )
@@ -844,6 +910,9 @@ bool cxxParserExtractVariableDeclarations(CXXTokenChain * pChain,unsigned int uF
844910 // Comma. Might have other declarations here.
845911 if (iCorkIndex != CORK_NIL )
846912 {
913+ if (pTokenBracketChain )
914+ cxxParserExtractMembersInitialization (pTokenBracketChain -> pChain ,
915+ iCorkIndex );
847916 cxxParserSetEndLineForTagInCorkQueue (iCorkIndex , t -> iLineNumber );
848917 iCorkIndex = CORK_NIL ;
849918 if (iCorkIndexFQ != CORK_NIL )
0 commit comments