Fixed problems with unknown macros for inline class methods in SymbolDatabase (#5621)
This commit is contained in:
parent
025850d961
commit
e0574feabd
|
@ -495,9 +495,9 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
function.hasBody = true;
|
function.hasBody = true;
|
||||||
|
|
||||||
// find start of function '{'
|
// find start of function '{'
|
||||||
while (end && end->str() != "{")
|
while (end && end->str() != "{" && end->str() != ";")
|
||||||
end = end->next();
|
end = end->next();
|
||||||
if (!end)
|
if (!end || end->str() == ";")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
scope->functionList.push_back(function);
|
scope->functionList.push_back(function);
|
||||||
|
@ -1415,9 +1415,12 @@ void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok)
|
||||||
Scope *new_scope = &scopeList.back();
|
Scope *new_scope = &scopeList.back();
|
||||||
|
|
||||||
// skip to start of function
|
// 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() == "{")
|
if (tok1->str() == "(" || tok1->str() == "{")
|
||||||
tok1 = tok1->link();
|
tok1 = tok1->link();
|
||||||
|
if (tok1->str() == ":")
|
||||||
|
foundInitLit = true;
|
||||||
tok1 = tok1->next();
|
tok1 = tok1->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@ private:
|
||||||
TEST_CASE(functionDeclarations);
|
TEST_CASE(functionDeclarations);
|
||||||
TEST_CASE(memberFunctionOfUnknownClassMacro1);
|
TEST_CASE(memberFunctionOfUnknownClassMacro1);
|
||||||
TEST_CASE(memberFunctionOfUnknownClassMacro2);
|
TEST_CASE(memberFunctionOfUnknownClassMacro2);
|
||||||
|
TEST_CASE(memberFunctionOfUnknownClassMacro3);
|
||||||
|
|
||||||
TEST_CASE(classWithFriend);
|
TEST_CASE(classWithFriend);
|
||||||
|
|
||||||
|
@ -974,6 +975,26 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void memberFunctionOfUnknownClassMacro2() {
|
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"
|
GET_SYMBOL_DB("class ScVbaFormatCondition { OUString getServiceImplName() THROW(whatever); };\n"
|
||||||
"void ScVbaValidation::getFormula1() {\n"
|
"void ScVbaValidation::getFormula1() {\n"
|
||||||
" sal_uInt16 nFlags = 0;\n"
|
" sal_uInt16 nFlags = 0;\n"
|
||||||
|
|
Loading…
Reference in New Issue