| 1512 | } |
| 1513 | |
| 1514 | bool 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 | |
| 1542 | const std::map<std::string, Library::WarnInfo>& Library::functionwarn() const |
| 1543 | { |
no test coverage detected