@@ -737,6 +737,33 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
737737 } else {
738738 tok = tok->link ();
739739 }
740+ } else if (Token::Match (tok, " %name% (" )) {
741+ if (Token::simpleMatch (tok->linkAt (1 ), " ) ;" )) {
742+ const Token *funcStart = nullptr ;
743+ const Token *argStart = nullptr ;
744+ const Token *declEnd = nullptr ;
745+ if (isFunction (tok, scope, &funcStart, &argStart, &declEnd)) {
746+ if (declEnd && declEnd->str () == " ;" ) {
747+ bool newFunc = true ; // Is this function already in the database?
748+ auto range = scope->functionMap .equal_range (tok->str ());
749+ for (std::multimap<std::string, const Function*>::const_iterator it = range.first ; it != range.second ; ++it) {
750+ if (it->second ->argsMatch (scope, it->second ->argDef , argStart, emptyString, 0 )) {
751+ newFunc = false ;
752+ break ;
753+ }
754+ }
755+ // save function prototype in database
756+ if (newFunc) {
757+ Function function (tok, scope, funcStart, argStart);
758+ if (function.isExtern ()) {
759+ scope->addFunction (std::move (function));
760+ tok = declEnd;
761+ }
762+ }
763+ continue ;
764+ }
765+ }
766+ }
740767 }
741768 // syntax error?
742769 if (!scope)
@@ -5902,6 +5929,10 @@ const Function* SymbolDatabase::findFunction(const Token* const tok) const
59025929 // find the scope this function is in
59035930 const Scope *currScope = tok->scope ();
59045931 while (currScope && currScope->isExecutable ()) {
5932+ if (const Function* f = currScope->findFunction (tok)) {
5933+ if (f->isExtern ())
5934+ return f;
5935+ }
59055936 if (currScope->functionOf )
59065937 currScope = currScope->functionOf ;
59075938 else
0 commit comments