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

Method matchArguments

lib/library.cpp:1514–1540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1512}
1513
1514bool Library::matchArguments(const Token *ftok, const std::string &functionName, const Function **func) const
1515{
1516 if (functionName.empty())
1517 return false;
1518 const auto it = utils::as_const(mData->mFunctions).find(functionName);
1519 if (it == mData->mFunctions.cend())
1520 return false;
1521 const int callargs = numberOfArgumentsWithoutAst(ftok);
1522 int args = 0;
1523 int firstOptionalArg = -1;
1524 for (const std::pair<const int, Library::ArgumentChecks> & argCheck : it->second.argumentChecks) {
1525 args = std::max(argCheck.first, args);
1526 if (argCheck.second.optional && (firstOptionalArg == -1 || firstOptionalArg > argCheck.first))
1527 firstOptionalArg = argCheck.first;
1528
1529 if (argCheck.second.formatstr || argCheck.second.variadic) {
1530 const bool b = args <= callargs;
1531 if (b && func)
1532 *func = &it->second;
1533 return b;
1534 }
1535 }
1536 const bool b = (firstOptionalArg < 0) ? args == callargs : (callargs >= firstOptionalArg-1 && callargs <= args);
1537 if (b && func)
1538 *func = &it->second;
1539 return b;
1540}
1541
1542const std::map<std::string, Library::WarnInfo>& Library::functionwarn() const
1543{

Callers 1

simplifyNamespaceStdMethod · 0.80

Calls 3

emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected