SymbolDatabase: Use ValueType::matchParameter for *var parameters

This commit is contained in:
Daniel Marjamäki 2019-08-01 13:29:44 +02:00
parent dbddc321e8
commit 2a17b897c5
1 changed files with 12 additions and 14 deletions

View File

@ -4155,22 +4155,20 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
// check for a match with reference of a variable
else if (Token::Match(arguments[j], "* %var% ,|)")) {
const Variable * callarg = check->getVariableFromVarId(arguments[j]->next()->varId());
if (callarg) {
const bool funcargref = (funcarg->typeEndToken()->str() == "&");
if (funcargref &&
(callarg->typeStartToken()->str() == funcarg->typeStartToken()->str() &&
callarg->typeStartToken()->isUnsigned() == funcarg->typeStartToken()->isUnsigned() &&
callarg->typeStartToken()->isLong() == funcarg->typeStartToken()->isLong())) {
same++;
} else {
ValueType::MatchResult res = ValueType::matchParameter(arguments[j]->valueType(), funcarg->valueType());
if (res == ValueType::MatchResult::SAME)
++same;
else if (res == ValueType::MatchResult::FALLBACK1)
++fallback1;
else if (res == ValueType::MatchResult::FALLBACK2)
++fallback2;
else if (res == ValueType::MatchResult::NOMATCH) {
// can't match so remove this function from possible matches
matches.erase(matches.begin() + i);
erased = true;
break;
}
}
}
// check for a match with address of a variable
else if (Token::Match(arguments[j], "& %var% ,|)")) {