better fix for #9392 that also handles namespaces (#2282)

This commit is contained in:
IOBYTE 2019-10-18 12:05:48 -04:00 committed by Daniel Marjamäki
parent e0093c99ce
commit 5658dfcaf3
2 changed files with 26 additions and 10 deletions

View File

@ -2394,6 +2394,13 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To
Function * func = findFunctionInScope(tok1, it2->scope, path, path_length);
if (func) {
if (!func->hasBody()) {
const Token *closeParen = (*tok)->next()->link();
if (closeParen) {
if (Token::simpleMatch(closeParen, ") = default ;")) {
func->isDefault(true);
return;
}
}
func->hasBody(true);
func->token = *tok;
func->arg = argStart;
@ -2461,11 +2468,8 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To
// normal function?
const Token *closeParen = (*tok)->next()->link();
if (closeParen) {
if (Token::Match(closeParen, ") = default|delete ;")) {
if (closeParen->strAt(2) == "default")
func->isDefault(true);
else
func->isDelete(true);
if (Token::simpleMatch(closeParen, ") = default ;")) {
func->isDefault(true);
return;
}

View File

@ -4284,11 +4284,23 @@ private:
}
void symboldatabase79() { // #9392
GET_SYMBOL_DB("class C { C(); };\n"
"C::C() = default;");
ASSERT(db->scopeList.size() == 2);
ASSERT(db->scopeList.back().functionList.size() == 1);
ASSERT(db->scopeList.back().functionList.front().isDefault() == true);
{
GET_SYMBOL_DB("class C { C(); };\n"
"C::C() = default;");
ASSERT(db->scopeList.size() == 2);
ASSERT(db->scopeList.back().functionList.size() == 1);
ASSERT(db->scopeList.back().functionList.front().isDefault() == true);
}
{
GET_SYMBOL_DB("namespace ns {\n"
"class C { C(); };\n"
"}\n"
"using namespace ns;\n"
"C::C() = default;");
ASSERT(db->scopeList.size() == 3);
ASSERT(db->scopeList.back().functionList.size() == 1);
ASSERT(db->scopeList.back().functionList.front().isDefault() == true);
}
}
void symboldatabase80() { // #9389