From f95fdd80ddc4705c8c6cb0563f52cef3cfc70a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 1 Aug 2019 14:30:00 +0200 Subject: [PATCH] SymbolDatabase: Refactoring findFunction --- lib/symboldatabase.cpp | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 8e0d2a0b2..991d386bc 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -4258,41 +4258,11 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const fallback1++; } - // check for a match with a char literal - else if (!funcarg->isArrayOrPointer() && Token::Match(arguments[j], "%char%")) { - 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; - } - - // check for a match with a boolean literal - else if (!funcarg->isArrayOrPointer() && Token::Match(arguments[j], "%bool% ,|)")) { - 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; - } - // check for a match with nullptr else if (funcarg->isPointer() && Token::Match(arguments[j], "nullptr|NULL ,|)")) { same++; } - // check that function argument type is not mismatching - else if (funcarg->isReference() && arguments[j]->str() == "&") { - // can't match so remove this function from possible matches - matches.erase(matches.begin() + i); - erased = true; - break; - } - // Try to evaluate the apparently more complex expression else { ValueType::MatchResult res = ValueType::matchParameter(arguments[j]->valueType(), funcarg->valueType()); @@ -4302,6 +4272,12 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const ++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; + } } }