From 2a17b897c5069f5d9156377f9ed0762db463dbe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 1 Aug 2019 13:29:44 +0200 Subject: [PATCH] SymbolDatabase: Use ValueType::matchParameter for *var parameters --- lib/symboldatabase.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 214618dc4..8e0d2a0b2 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -4155,20 +4155,18 @@ 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 { - // can't match so remove this function from possible matches - matches.erase(matches.begin() + i); - erased = true; - break; - } + 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; } }