diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 79ce8282f..966e8aa0c 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -998,6 +998,7 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const tok->strAt(-1) == "::" || tok->strAt(-1) == "~" || // or a scope qualifier in front of tok outerScope->isClassOrStruct()) && // or a ctor/dtor (Token::Match(tok->next()->link(), ") const| ;|{|=") || + (Token::Match(tok->next()->link(), ") %var% ;|{") && tok->next()->link()->next()->isUpperCaseName()) || Token::Match(tok->next()->link(), ") : ::| %var% (|::|<|{") || Token::Match(tok->next()->link(), ") = delete|default ;"))) { *funcStart = tok; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 3fb5e36ef..a0179464c 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -149,7 +149,8 @@ private: TEST_CASE(hasGlobalVariables2); TEST_CASE(hasGlobalVariables3); - TEST_CASE(checkTypeStartEndToken); + TEST_CASE(checkTypeStartEndToken1); + TEST_CASE(checkTypeStartEndToken2); // handling for unknown macro: 'void f() MACRO {..' TEST_CASE(functionArgs1); TEST_CASE(functionArgs2); @@ -964,7 +965,7 @@ private: } } - void checkTypeStartEndToken() { + void checkTypeStartEndToken1() { GET_SYMBOL_DB("static std::string i;\n" "static const std::string j;\n" "const std::string* k;\n" @@ -987,6 +988,22 @@ private: } } + void checkTypeStartEndToken2() { + GET_SYMBOL_DB("class CodeGenerator {\n" + " DiagnosticsEngine Diags;\n" + "public:\n" + " void Initialize() {\n" + " Builder.reset(Diags);\n" + " }\n" + "\n" + " void HandleTagDeclRequiredDefinition() LLVM_OVERRIDE {\n" + " if (Diags.hasErrorOccurred())\n" + " return;\n" + " }\n" + "};"); + ASSERT_EQUALS("DiagnosticsEngine", db->getVariableFromVarId(1)->typeStartToken()->str()); + } + void check(const char code[], bool debug = true) { // Clear the error log errout.str("");