From 4a02ca8202a475897ddee1723e8158f283a2cce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 28 Sep 2013 11:44:26 +0200 Subject: [PATCH] SymbolDatabase: handle method with unknown macro 'void f() MACRO {..}' --- lib/symboldatabase.cpp | 1 + test/testsymboldatabase.cpp | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) 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("");