@@ -2970,47 +2970,51 @@ void Tokenizer::setVarIdPass2()
29702970 std::map<const Token *, std::string> endOfScope;
29712971 std::list<std::string> scope;
29722972 std::list<const Token *> usingnamespaces;
2973- for (Token *tok2 = list.front (); tok2; tok2 = tok2 ->next ()) {
2974- if (!tok2 ->previous () || Token::Match (tok2 ->previous (), " [;{}]" )) {
2975- if (Token::Match (tok2 , " using namespace %name% ::|;" )) {
2976- const Token *endtok = tok2 ->tokAt (2 );
2973+ for (Token *tok = list.front (); tok; tok = tok ->next ()) {
2974+ if (!tok ->previous () || Token::Match (tok ->previous (), " [;{}]" )) {
2975+ if (Token::Match (tok , " using namespace %name% ::|;" )) {
2976+ const Token *endtok = tok ->tokAt (2 );
29772977 while (Token::Match (endtok, " %name% ::" ))
29782978 endtok = endtok->tokAt (2 );
29792979 if (Token::Match (endtok, " %name% ;" ))
2980- usingnamespaces.push_back (tok2 ->tokAt (2 ));
2981- } else if (Token::Match (tok2 , " namespace %name% {" )) {
2982- scope.push_back (tok2 ->strAt (1 ));
2983- endOfScope[tok2 ->linkAt (2 )] = tok2 ->strAt (1 );
2980+ usingnamespaces.push_back (tok ->tokAt (2 ));
2981+ } else if (Token::Match (tok , " namespace %name% {" )) {
2982+ scope.push_back (tok ->strAt (1 ));
2983+ endOfScope[tok ->linkAt (2 )] = tok ->strAt (1 );
29842984 }
29852985 }
29862986
2987- if (tok2 ->str () == " }" ) {
2988- std::map<const Token *, std::string>::iterator it = endOfScope.find (tok2 );
2987+ if (tok ->str () == " }" ) {
2988+ std::map<const Token *, std::string>::iterator it = endOfScope.find (tok );
29892989 if (it != endOfScope.end ())
29902990 scope.remove (it->second );
29912991 }
29922992
2993- const Token* tok3 = nullptr ;
2994- if (Token::Match (tok2 , " %name% :: ~| %name%" ))
2995- tok3 = tok2 ->next ();
2996- else if (Token::Match (tok2 , " %name% <" ) && Token::Match (tok2 ->next ()->findClosingBracket ()," > :: ~| %name%" ))
2997- tok3 = tok2 ->next ()->findClosingBracket ()->next ();
2993+ Token* const tok1 = tok ;
2994+ if (Token::Match (tok-> previous () , " !!:: %name% :: ~| %name%" ))
2995+ tok = tok ->next ();
2996+ else if (Token::Match (tok-> previous () , " !!:: %name% <" ) && Token::Match (tok ->next ()->findClosingBracket ()," > :: ~| %name%" ))
2997+ tok = tok ->next ()->findClosingBracket ()->next ();
29982998 else
29992999 continue ;
30003000
3001- while (Token::Match (tok3, " :: ~| %name%" )) {
3002- tok3 = tok3->next ();
3003- if (tok3->str () == " ~" )
3004- tok3 = tok3->next ();
3005- tok3 = tok3->next ();
3001+ while (Token::Match (tok, " :: ~| %name%" )) {
3002+ tok = tok->next ();
3003+ if (tok->str () == " ~" )
3004+ tok = tok->next ();
3005+ else if (Token::Match (tok, " %name% <" ) && Token::Match (tok->next ()->findClosingBracket ()," > :: ~| %name%" ))
3006+ tok = tok->next ()->findClosingBracket ()->next ();
3007+ else if (Token::Match (tok, " %name% ::" ))
3008+ tok = tok->next ();
3009+ else
3010+ break ;
30063011 }
3007- if (!tok3)
3008- syntaxError (tok2);
3009- const std::string& str3 = tok3->str ();
3010- if (str3 == " (" )
3011- allMemberFunctions.push_back (Member (scope, usingnamespaces, tok2));
3012- else if (str3 != " ::" && tok2->strAt (-1 ) != " ::" ) // Support only one depth
3013- allMemberVars.push_back (Member (scope, usingnamespaces, tok2));
3012+ if (!tok)
3013+ syntaxError (tok1);
3014+ if (Token::Match (tok, " %name% (" ))
3015+ allMemberFunctions.push_back (Member (scope, usingnamespaces, tok1));
3016+ else
3017+ allMemberVars.push_back (Member (scope, usingnamespaces, tok1));
30143018 }
30153019 }
30163020
0 commit comments