Skip to content

Commit

Permalink
Fix #13004 (SymbolDatabase: Wrong overloaded function is called) (dan…
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Aug 22, 2024
1 parent 0a11422 commit 6faed30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ SymbolDatabase::SymbolDatabase(Tokenizer& tokenizer, const Settings& settings, E
createSymbolDatabaseVariableSymbolTable();
createSymbolDatabaseSetScopePointers();
createSymbolDatabaseSetVariablePointers();
setValueTypeInTokenList(false);
createSymbolDatabaseSetTypePointers();
setValueTypeInTokenList(false);
createSymbolDatabaseSetFunctionPointers(true);
createSymbolDatabaseSetSmartPointerType();
setValueTypeInTokenList(false);
Expand Down
11 changes: 11 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ class TestSymbolDatabase : public TestFixture {
TEST_CASE(findFunction52);
TEST_CASE(findFunction53);
TEST_CASE(findFunction54);
TEST_CASE(findFunction55); // #31004
TEST_CASE(findFunctionContainer);
TEST_CASE(findFunctionExternC);
TEST_CASE(findFunctionGlobalScope); // ::foo
Expand Down Expand Up @@ -8314,6 +8315,16 @@ class TestSymbolDatabase : public TestFixture {
}
}

void findFunction55() {
GET_SYMBOL_DB("struct Token { int x; };\n"
"static void f(std::size_t s);\n"
"static void f(const Token* ptr);\n"
"static void f2(const std::vector<Token*>& args) { f(args[0]); }\n");
const Token* f = Token::findsimplematch(tokenizer.tokens(), "f ( args [ 0 ] )");
ASSERT(f && f->function());
ASSERT(Token::simpleMatch(f->function()->tokenDef, "f ( const Token * ptr ) ;"));
}

void findFunctionContainer() {
{
GET_SYMBOL_DB("void dostuff(std::vector<int> v);\n"
Expand Down

0 comments on commit 6faed30

Please sign in to comment.