@@ -2330,19 +2330,25 @@ static void setVarIdClassDeclaration(Token * const startToken,
23302330
23312331// Update the variable ids..
23322332// Parse each function..
2333- static void setVarIdClassFunction (Token * const startToken,
2333+ static void setVarIdClassFunction (const std::string &classname,
2334+ Token * const startToken,
23342335 const Token * const endToken,
23352336 const std::map<std::string, unsigned int > &varlist,
23362337 std::map<unsigned int , std::map<std::string,unsigned int > > *structMembers,
23372338 unsigned int *_varId)
23382339{
23392340 for (Token *tok2 = startToken; tok2 && tok2 != endToken; tok2 = tok2->next ()) {
2340- if (tok2->varId () == 0 && (tok2->previous ()->str () != " ." || tok2->strAt (-2 ) == " this" )) {
2341- const std::map<std::string,unsigned int >::const_iterator it = varlist.find (tok2->str ());
2342- if (it != varlist.end ()) {
2343- tok2->varId (it->second );
2344- setVarIdStructMembers (&tok2, structMembers, _varId);
2345- }
2341+ if (tok2->varId () != 0 || !tok2->isName ())
2342+ continue ;
2343+ if (Token::Match (tok2->tokAt (-2 ), (" !!" +classname+" :: " ).c_str ()))
2344+ continue ;
2345+ if (Token::Match (tok2->tokAt (-2 ), " !!this . " ))
2346+ continue ;
2347+
2348+ const std::map<std::string,unsigned int >::const_iterator it = varlist.find (tok2->str ());
2349+ if (it != varlist.end ()) {
2350+ tok2->varId (it->second );
2351+ setVarIdStructMembers (&tok2, structMembers, _varId);
23462352 }
23472353 }
23482354}
@@ -2594,7 +2600,7 @@ void Tokenizer::setVarId()
25942600 if (Token::Match (tok2, " ) const|volatile| {" )) {
25952601 while (tok2->str () != " {" )
25962602 tok2 = tok2->next ();
2597- setVarIdClassFunction (tok2, tok2->link (), varlist, &structMembers, &_varId);
2603+ setVarIdClassFunction (classname, tok2, tok2->link (), varlist, &structMembers, &_varId);
25982604 }
25992605
26002606 // constructor with initializer list
@@ -2607,7 +2613,7 @@ void Tokenizer::setVarId()
26072613 tok3 = tok3->linkAt (3 );
26082614 }
26092615 if (Token::simpleMatch (tok3, " ) {" )) {
2610- setVarIdClassFunction (tok2, tok3->next ()->link (), varlist, &structMembers, &_varId);
2616+ setVarIdClassFunction (classname, tok2, tok3->next ()->link (), varlist, &structMembers, &_varId);
26112617 }
26122618 }
26132619 }
0 commit comments