Skip to content

Commit 6faed30

Browse files
authored
Fix #13004 (SymbolDatabase: Wrong overloaded function is called) (danmar#6716)
1 parent 0a11422 commit 6faed30

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ SymbolDatabase::SymbolDatabase(Tokenizer& tokenizer, const Settings& settings, E
7676
createSymbolDatabaseVariableSymbolTable();
7777
createSymbolDatabaseSetScopePointers();
7878
createSymbolDatabaseSetVariablePointers();
79-
setValueTypeInTokenList(false);
8079
createSymbolDatabaseSetTypePointers();
80+
setValueTypeInTokenList(false);
8181
createSymbolDatabaseSetFunctionPointers(true);
8282
createSymbolDatabaseSetSmartPointerType();
8383
setValueTypeInTokenList(false);

test/testsymboldatabase.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ class TestSymbolDatabase : public TestFixture {
518518
TEST_CASE(findFunction52);
519519
TEST_CASE(findFunction53);
520520
TEST_CASE(findFunction54);
521+
TEST_CASE(findFunction55); // #31004
521522
TEST_CASE(findFunctionContainer);
522523
TEST_CASE(findFunctionExternC);
523524
TEST_CASE(findFunctionGlobalScope); // ::foo
@@ -8314,6 +8315,16 @@ class TestSymbolDatabase : public TestFixture {
83148315
}
83158316
}
83168317

8318+
void findFunction55() {
8319+
GET_SYMBOL_DB("struct Token { int x; };\n"
8320+
"static void f(std::size_t s);\n"
8321+
"static void f(const Token* ptr);\n"
8322+
"static void f2(const std::vector<Token*>& args) { f(args[0]); }\n");
8323+
const Token* f = Token::findsimplematch(tokenizer.tokens(), "f ( args [ 0 ] )");
8324+
ASSERT(f && f->function());
8325+
ASSERT(Token::simpleMatch(f->function()->tokenDef, "f ( const Token * ptr ) ;"));
8326+
}
8327+
83178328
void findFunctionContainer() {
83188329
{
83198330
GET_SYMBOL_DB("void dostuff(std::vector<int> v);\n"

0 commit comments

Comments
 (0)