SymbolDatabase: handle method with unknown macro 'void f() MACRO {..}'

This commit is contained in:
Daniel Marjamäki 2013-09-28 11:44:26 +02:00
parent c2a8f6f59a
commit 4a02ca8202
2 changed files with 20 additions and 2 deletions

View File

@ -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;

View File

@ -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("");