From 9e515c860f215da0b4c3b1e9fc56de9ee6591358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 22 Aug 2024 16:12:20 +0200 Subject: [PATCH] Fix #13004 (SymbolDatabase: Wrong overloaded function is called) --- lib/symboldatabase.cpp | 2 +- test/testsymboldatabase.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index dd79300bbcb..12c05dc7ebc 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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); diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 0992f24cd81..427d21ef4e3 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -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 @@ -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& 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 v);\n"