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

View File

@ -4284,12 +4284,24 @@ private:
} }
void symboldatabase79() { // #9392 void symboldatabase79() { // #9392
{
GET_SYMBOL_DB("class C { C(); };\n" GET_SYMBOL_DB("class C { C(); };\n"
"C::C() = default;"); "C::C() = default;");
ASSERT(db->scopeList.size() == 2); ASSERT(db->scopeList.size() == 2);
ASSERT(db->scopeList.back().functionList.size() == 1); ASSERT(db->scopeList.back().functionList.size() == 1);
ASSERT(db->scopeList.back().functionList.front().isDefault() == true); 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 void symboldatabase80() { // #9389
{ {