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
18 changes: 14 additions & 4 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2764,11 +2764,21 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
((first->strAt(2) != "const" && second->strAt(2) == "const") ||
(first->strAt(2) == "const" && second->strAt(2) != "const"))) {
if (first->strAt(2) != "const") {
first = first->next();
second = second->tokAt(2);
if (Token::Match(first->tokAt(2), "%name%| ,|)") && Token::Match(second->tokAt(3), "%name%| ,|)")) {
first = first->tokAt(Token::Match(first->tokAt(2), "%name%") ? 2 : 1);
second = second->tokAt(Token::Match(second->tokAt(3), "%name%") ? 3 : 2);
} else {
first = first->next();
second = second->tokAt(2);
}
} else {
first = first->tokAt(2);
second = second->next();
if (Token::Match(second->tokAt(2), "%name%| ,|)") && Token::Match(first->tokAt(3), "%name%| ,|)")) {
first = first->tokAt(Token::Match(first->tokAt(3), "%name%") ? 3 : 2);
second = second->tokAt(Token::Match(second->tokAt(2), "%name%") ? 2 : 1);
} else {
first = first->tokAt(2);
second = second->next();
}
}
}

Expand Down
20 changes: 20 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ class TestSymbolDatabase : public TestFixture {
TEST_CASE(symboldatabase101);
TEST_CASE(symboldatabase102);
TEST_CASE(symboldatabase103);
TEST_CASE(symboldatabase104);

TEST_CASE(createSymbolDatabaseFindAllScopes1);
TEST_CASE(createSymbolDatabaseFindAllScopes2);
Expand Down Expand Up @@ -5073,6 +5074,25 @@ class TestSymbolDatabase : public TestFixture {
ASSERT_EQUALS("", errout.str());
}

void symboldatabase104() { // #11535
GET_SYMBOL_DB("struct S {\n"
" void f1(char* const c);\n"
" void f2(char* const c);\n"
" void f3(char* const);\n"
" void f4(char* c);\n"
" void f5(char* c);\n"
" void f6(char*);\n"
"};\n"
"void S::f1(char* c) {}\n"
"void S::f2(char*) {}\n"
"void S::f3(char* c) {}\n"
"void S::f4(char* const c) {}\n"
"void S::f5(char* const) {}\n"
"void S::f6(char* const c) {}\n");
ASSERT(db != nullptr);
ASSERT_EQUALS("", errout.str());
}

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