Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2353,11 +2353,15 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se

int arg_path_length = path_length;
int offset = 0;
int openParen = 0;

while (first->str() == second->str() &&
first->isLong() == second->isLong() &&
first->isUnsigned() == second->isUnsigned()) {

if (first->str() == "(")
openParen++;

// skip optional type information
if (Token::Match(first->next(), "struct|enum|union|class"))
first = first->next();
Expand All @@ -2374,7 +2378,10 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se

// at end of argument list
if (first->str() == ")") {
return true;
if (openParen == 1)
return true;
else
--openParen;
}

// skip default value assignment
Expand Down Expand Up @@ -2480,8 +2487,11 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
std::string param = path;

if (Token::simpleMatch(second->next(), param.c_str(), param.size())) {
second = second->tokAt(int(arg_path_length));
arg_path_length = 0;
// check for redundant qualification before skipping it
if (!Token::simpleMatch(first->next(), param.c_str(), param.size())) {
second = second->tokAt(int(arg_path_length));
arg_path_length = 0;
}
}

// nested or base class variable
Expand Down
15 changes: 15 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ class TestSymbolDatabase: public TestFixture {
TEST_CASE(symboldatabase88); // #10040 (using namespace)
TEST_CASE(symboldatabase89); // valuetype name
TEST_CASE(symboldatabase90);
TEST_CASE(symboldatabase91);

TEST_CASE(createSymbolDatabaseFindAllScopes1);

Expand Down Expand Up @@ -4658,6 +4659,20 @@ class TestSymbolDatabase: public TestFixture {
ASSERT(functok->function()->name() == "foo");
}

void symboldatabase91() {
GET_SYMBOL_DB("namespace Fred {\n"
" struct Value {};\n"
" void foo(const std::vector<std::function<void(const Fred::Value &)>> &callbacks);\n"
"}\n"
"void Fred::foo(const std::vector<std::function<void(const Fred::Value &)>> &callbacks) { }");
ASSERT_EQUALS("", errout.str());
const Token *functok = Token::findsimplematch(tokenizer.tokens(),
"foo ( const std :: vector < std :: function < void ( const Fred :: Value & ) > > & callbacks ) { }");
ASSERT(functok);
ASSERT(functok->function());
ASSERT(functok->function()->name() == "foo");
}

void createSymbolDatabaseFindAllScopes1() {
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
ASSERT(db->scopeList.size() == 3);
Expand Down