SymbolDatabase::findFunction: For string literal, a std::string parameter is a better match than a void* parameter

This commit is contained in:
Daniel Marjamäki 2019-07-30 21:20:01 +02:00
parent f5c269a191
commit e58e51ee14
2 changed files with 4 additions and 4 deletions

View File

@ -4205,7 +4205,7 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
} }
// check for a match with a numeric literal // check for a match with a numeric literal
else if (Token::Match(arguments[j], "%num% ,|)")) { else if (Token::Match(arguments[j], "%num%")) {
const Token *calltok = arguments[j]; const Token *calltok = arguments[j];
if (funcarg->isPointer() && MathLib::isNullValue(calltok->str())) { if (funcarg->isPointer() && MathLib::isNullValue(calltok->str())) {
fallback1++; fallback1++;
@ -4221,7 +4221,7 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
} }
// check for a match with a string literal // check for a match with a string literal
else if (Token::Match(arguments[j], "%str% ,|)")) { else if (Token::Match(arguments[j], "%str%")) {
ValueType::MatchResult res = ValueType::matchParameter(arguments[j]->valueType(), funcarg->valueType()); ValueType::MatchResult res = ValueType::matchParameter(arguments[j]->valueType(), funcarg->valueType());
if (res == ValueType::MatchResult::SAME) if (res == ValueType::MatchResult::SAME)
++same; ++same;
@ -4230,7 +4230,7 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
else if (res == ValueType::MatchResult::FALLBACK2) else if (res == ValueType::MatchResult::FALLBACK2)
++fallback2; ++fallback2;
else if (funcarg->isStlStringType()) else if (funcarg->isStlStringType())
fallback2++; fallback1++;
} }
// check for a match with a char literal // check for a match with a char literal

View File

@ -5138,7 +5138,7 @@ private:
ASSERT_EQUALS(true, f && f->function() && f->function()->tokenDef->linenr() == 5); ASSERT_EQUALS(true, f && f->function() && f->function()->tokenDef->linenr() == 5);
f = Token::findsimplematch(tokenizer.tokens(), "foo ( \"\" ) ;"); f = Token::findsimplematch(tokenizer.tokens(), "foo ( \"\" ) ;");
ASSERT_EQUALS(true, f && f->function() && f->function()->tokenDef->linenr() == 5); ASSERT_EQUALS(true, f && f->function() && f->function()->tokenDef->linenr() == 1);
} }
void findFunction14() { void findFunction14() {