Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #13004 (SymbolDatabase: Wrong overloaded function is called) #6716

Merged
merged 1 commit into from
Aug 22, 2024
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
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
Loading