Fixed problems with unknown macros for inline class methods in SymbolDatabase (#5621)

This commit is contained in:
PKEuS 2014-03-31 21:04:01 +02:00
parent 025850d961
commit e0574feabd
2 changed files with 27 additions and 3 deletions

View File

@ -495,9 +495,9 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
function.hasBody = true;
// find start of function '{'
while (end && end->str() != "{")
while (end && end->str() != "{" && end->str() != ";")
end = end->next();
if (!end)
if (!end || end->str() == ";")
continue;
scope->functionList.push_back(function);
@ -1415,9 +1415,12 @@ void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok)
Scope *new_scope = &scopeList.back();
// skip to start of function
while (tok1 && ((tok1->str() != "{") || (tok1->previous() && tok1->previous()->isName() && tok1->strAt(-1) != "const" && Token::Match(tok1->link()->next(), "%type%|,|{")))) {
bool foundInitLit = false;
while (tok1 && (tok1->str() != "{" || (foundInitLit && tok1->previous()->isName()))) {
if (tok1->str() == "(" || tok1->str() == "{")
tok1 = tok1->link();
if (tok1->str() == ":")
foundInitLit = true;
tok1 = tok1->next();
}

View File

@ -142,6 +142,7 @@ private:
TEST_CASE(functionDeclarations);
TEST_CASE(memberFunctionOfUnknownClassMacro1);
TEST_CASE(memberFunctionOfUnknownClassMacro2);
TEST_CASE(memberFunctionOfUnknownClassMacro3);
TEST_CASE(classWithFriend);
@ -974,6 +975,26 @@ private:
}
void memberFunctionOfUnknownClassMacro2() {
GET_SYMBOL_DB("class ScVbaFormatCondition { OUString getServiceImplName() SAL_OVERRIDE {} };\n"
"void getFormula1() {\n"
" sal_uInt16 nFlags = 0;\n"
" if (pDocSh && !getCellRangesForAddress(nFlags)) ;\n"
"}");
ASSERT(db && errout.str() == "");
if (db) {
const Scope *scope = db->findScopeByName("getFormula1");
ASSERT(scope != nullptr);
ASSERT(scope && scope->nestedIn == &db->scopeList.front());
scope = db->findScopeByName("getServiceImplName");
ASSERT(scope != nullptr);
ASSERT(scope && scope->nestedIn && scope->nestedIn->className == "ScVbaFormatCondition");
}
}
void memberFunctionOfUnknownClassMacro3() {
GET_SYMBOL_DB("class ScVbaFormatCondition { OUString getServiceImplName() THROW(whatever); };\n"
"void ScVbaValidation::getFormula1() {\n"
" sal_uInt16 nFlags = 0;\n"