MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / findFunctionInScope

Method findFunctionInScope

lib/symboldatabase.cpp:6776–6806  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6774//---------------------------------------------------------------------------
6775
6776Function * SymbolDatabase::findFunctionInScope(const Token *func, const Scope *ns, const std::string & path, nonneg int path_length)
6777{
6778 const Function * function = nullptr;
6779 const bool destructor = func->strAt(-1) == "~";
6780
6781 auto range = ns->functionMap.equal_range(func->str());
6782 for (auto it = range.first; it != range.second; ++it) {
6783 if (it->second->argsMatch(ns, it->second->argDef, func->next(), path, path_length) &&
6784 it->second->isDestructor() == destructor) {
6785 function = it->second;
6786 break;
6787 }
6788 }
6789
6790 if (!function) {
6791 const Scope * scope = ns->findRecordInNestedList(func->str());
6792 if (scope && Token::Match(func->tokAt(1), "::|<")) {
6793 if (func->strAt(1) == "::")
6794 func = func->tokAt(2);
6795 else if (func->linkAt(1))
6796 func = func->linkAt(1)->tokAt(2);
6797 else
6798 return nullptr;
6799 if (func->str() == "~")
6800 func = func->next();
6801 function = findFunctionInScope(func, scope, path, path_length);
6802 }
6803 }
6804
6805 return const_cast<Function *>(function);
6806}
6807
6808//---------------------------------------------------------------------------
6809

Callers

nothing calls this directly

Calls 6

argsMatchMethod · 0.80
nextMethod · 0.80
linkAtMethod · 0.80
strMethod · 0.45
tokAtMethod · 0.45

Tested by

no test coverage detected