@@ -608,12 +608,27 @@ bool Library::isargvalid(const Token *ftok, int argnr, const MathLib::bigint arg
608608 return false ;
609609}
610610
611+ static std::string functionName (const Token *ftok)
612+ {
613+ if (Token::simpleMatch (ftok->previous (), " ." ))
614+ return " " ;
615+ if (!Token::Match (ftok->tokAt (-2 ), " %name% ::" ))
616+ return ftok->str ();
617+ std::string ret (ftok->str ());
618+ ftok = ftok->tokAt (-2 );
619+ while (Token::Match (ftok, " %name% ::" )) {
620+ ret = ftok->str () + " ::" + ret;
621+ ftok = ftok->tokAt (-2 );
622+ }
623+ return ret;
624+ }
625+
611626const Library::ArgumentChecks * Library::getarg (const Token *ftok, int argnr) const
612627{
613628 if (isNotLibraryFunction (ftok))
614629 return nullptr ;
615630 std::map<std::string, std::map<int , ArgumentChecks> >::const_iterator it1;
616- it1 = argumentChecks.find (ftok-> str ( ));
631+ it1 = argumentChecks.find (functionName (ftok ));
617632 if (it1 == argumentChecks.end ())
618633 return nullptr ;
619634 const std::map<int ,ArgumentChecks>::const_iterator it2 = it1->second .find (argnr);
@@ -678,12 +693,13 @@ const Library::Container* Library::detectContainer(const Token* typeStart) const
678693 }
679694 return nullptr ;
680695}
696+
681697// returns true if ftok is not a library function
682698bool Library::isNotLibraryFunction (const Token *ftok) const
683699{
684700 // methods are not library functions
685701 // called from tokenizer, ast is not created properly yet
686- if (Token::Match (ftok->previous ()," ::| ." ))
702+ if (Token::Match (ftok->previous ()," ." ))
687703 return true ;
688704 if (ftok->function () && ftok->function ()->nestedIn && ftok->function ()->nestedIn ->type != Scope::eGlobal)
689705 return true ;
@@ -701,7 +717,7 @@ bool Library::isNotLibraryFunction(const Token *ftok) const
701717 else if (tok->link () && Token::Match (tok, " <|(|[" ))
702718 tok = tok->link ();
703719 }
704- const std::map<std::string, std::map<int , ArgumentChecks> >::const_iterator it = argumentChecks.find (ftok-> str ( ));
720+ const std::map<std::string, std::map<int , ArgumentChecks> >::const_iterator it = argumentChecks.find (functionName (ftok ));
705721 if (it == argumentChecks.end ())
706722 return (callargs != 0 );
707723 int args = 0 ;
@@ -720,7 +736,7 @@ bool Library::isnoreturn(const Token *ftok) const
720736 return true ;
721737 if (isNotLibraryFunction (ftok))
722738 return false ;
723- std::map<std::string, bool >::const_iterator it = _noreturn.find (ftok-> str ( ));
739+ std::map<std::string, bool >::const_iterator it = _noreturn.find (functionName (ftok ));
724740 return (it != _noreturn.end () && it->second );
725741}
726742
@@ -730,7 +746,7 @@ bool Library::isnotnoreturn(const Token *ftok) const
730746 return false ;
731747 if (isNotLibraryFunction (ftok))
732748 return false ;
733- std::map<std::string, bool >::const_iterator it = _noreturn.find (ftok-> str ( ));
749+ std::map<std::string, bool >::const_iterator it = _noreturn.find (functionName (ftok ));
734750 return (it != _noreturn.end () && !it->second );
735751}
736752
0 commit comments