diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index f8e682d3e..59d577ce2 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2923,8 +2923,6 @@ const Function* Scope::findFunction(const Token *tok) const std::list::const_iterator it; // this is a function call so try to find it based on name and arguments - // if more than 1 function matches (it is overloaded) and we dont see which function is called, return 0 - const Function *foundfunction = nullptr; for (it = functionList.begin(); it != functionList.end(); ++it) { if (it->tokenDef->str() == tok->str()) { const Function *func = &*it; @@ -2952,19 +2950,11 @@ const Function* Scope::findFunction(const Token *tok) const // check for argument count match or default arguments if (args == func->argCount() || - (args < func->argCount() && args >= func->minArgCount())) { - if (foundfunction == nullptr) - foundfunction = func; - else { - // Two or more functions match, don't guess which one is right - return nullptr; - } - } + (args < func->argCount() && args >= func->minArgCount())) + return func; } } } - if (foundfunction) - return foundfunction; // check in base classes if (isClassOrStruct() && definedType && !definedType->derivedFrom.empty()) { diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 2634a0107..05eba1336 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -228,7 +228,6 @@ private: TEST_CASE(findFunction2); // mismatch: parameter passed by address => reference argument TEST_CASE(findFunction3); TEST_CASE(findFunction4); - TEST_CASE(findFunction5); // #6230: don't guess when there are overloaded functions TEST_CASE(noexceptFunction1); TEST_CASE(noexceptFunction2); @@ -2333,16 +2332,6 @@ private: TODO_ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 8, false); } - void findFunction5() { - GET_SYMBOL_DB("void f(A x);\n" - "void f(B x);\n" - "void caller() {\n" - " f(1);\n" - "}"); - const Token *f = Token::findsimplematch(tokenizer.tokens(), "f ( 1 ) ;"); - ASSERT_EQUALS(true, db && f && !f->function()); - } - #define FUNC(x) const Function *x = findFunctionByName(#x, &db->scopeList.front()); \ ASSERT_EQUALS(true, x != nullptr); \ if (x) ASSERT_EQUALS(true, x->isNoExcept);