Revert "Fixed #6230 (SymbolDatabase: Wrong function() is set for token)"

This reverts commit 685fce6b91.
This commit is contained in:
Daniel Marjamäki 2014-11-11 07:29:16 +01:00
parent ea765c24f2
commit 189dfd64f7
2 changed files with 2 additions and 23 deletions

View File

@ -2923,8 +2923,6 @@ const Function* Scope::findFunction(const Token *tok) const
std::list<Function>::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()) {

View File

@ -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);