@@ -774,6 +774,19 @@ static bool areAllParamsTypes(const std::vector<const Token *> ¶ms)
774774 });
775775}
776776
777+ static bool isTemplateInstantion (const Token* tok)
778+ {
779+ if (!tok->isName () || (tok->isKeyword () && !tok->isOperatorKeyword ()))
780+ return false ;
781+ if (Token::Match (tok->tokAt (-1 ), " %type% %name% ::|<" ))
782+ return true ;
783+ if (Token::Match (tok->tokAt (-2 ), " [,:] private|protected|public %name% ::|<" ))
784+ return true ;
785+ if (Token::Match (tok->tokAt (-1 ), " (|{|}|;|=|>|<<|:|.|*|&|return|<|,|!|[ %name% ::|<|(" ))
786+ return true ;
787+ return Token::Match (tok->tokAt (-2 ), " (|{|}|;|=|<<|:|.|*|&|return|<|,|!|[ :: %name% ::|<|(" );
788+ }
789+
777790void TemplateSimplifier::getTemplateInstantiations ()
778791{
779792 std::multimap<std::string, const TokenAndName *> functionNameMap;
@@ -830,9 +843,7 @@ void TemplateSimplifier::getTemplateInstantiations()
830843 Token *tok2 = Token::findsimplematch (tok->tokAt (2 ), " ;" );
831844 if (tok2)
832845 tok = tok2;
833- } else if (Token::Match (tok->previous (), " (|{|}|;|=|>|<<|:|.|*|&|return|<|,|!|[ %name% ::|<|(" ) ||
834- Token::Match (tok->previous (), " %type% %name% ::|<" ) ||
835- Token::Match (tok->tokAt (-2 ), " [,:] private|protected|public %name% ::|<" )) {
846+ } else if (isTemplateInstantion (tok)) {
836847 if (!tok->scopeInfo ())
837848 syntaxError (tok);
838849 std::string scopeName = tok->scopeInfo ()->name ;
0 commit comments