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
4 changes: 3 additions & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,16 +1100,18 @@ void SymbolDatabase::createSymbolDatabaseSetFunctionPointers(bool firstPass)
if (tok->next()->str() == ">" && !tok->next()->link())
continue;

bool isTemplateArg = false;
if (tok->next()->str() != "(") {
const Token *start = tok;
while (Token::Match(start->tokAt(-2), "%name% ::"))
start = start->tokAt(-2);
if (!Token::Match(start->previous(), "[(,<=]") && !Token::Match(start->tokAt(-2), "[(,<=] &") && !Token::Match(start, "%name% ;"))
continue;
isTemplateArg = Token::simpleMatch(start->previous(), "<") || Token::simpleMatch(start->tokAt(-2), "<");
}

const Function *function = findFunction(tok);
if (!function)
if (!function || (isTemplateArg && function->isConstructor()))
continue;

const_cast<Token *>(tok)->function(function);
Expand Down
13 changes: 13 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ class TestSymbolDatabase : public TestFixture {
TEST_CASE(findFunction44); // #11182
TEST_CASE(findFunction45);
TEST_CASE(findFunction46);
TEST_CASE(findFunction47);
TEST_CASE(findFunctionContainer);
TEST_CASE(findFunctionExternC);
TEST_CASE(findFunctionGlobalScope); // ::foo
Expand Down Expand Up @@ -7149,6 +7150,18 @@ class TestSymbolDatabase : public TestFixture {
ASSERT_EQUALS(3, functok->function()->tokenDef->linenr());
}

void findFunction47() {
GET_SYMBOL_DB("struct S {\n"
" S() {}\n"
" std::list<S> l;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
const Token* typeTok = Token::findsimplematch(tokenizer.tokens(), "S >");
ASSERT(typeTok && typeTok->type());
ASSERT(typeTok->type()->name() == "S");
ASSERT_EQUALS(1, typeTok->type()->classDef->linenr());
}

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