SymbolDatabase; Refactoring, use Tokenizer::isFunctionHead to skip function attributes

This commit is contained in:
Daniel Marjamäki 2020-09-03 11:21:12 +02:00
parent 974b6fb8e5
commit 3fe46239cf
2 changed files with 5 additions and 8 deletions

View File

@ -2637,9 +2637,8 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To
if (!func->hasBody()) {
const Token *closeParen = (*tok)->next()->link();
if (closeParen) {
if (Token::Match(closeParen, ") noexcept| = default ;") ||
(Token::simpleMatch(closeParen, ") noexcept (") &&
Token::simpleMatch(closeParen->linkAt(2), ") = default ;"))) {
const Token *eq = mTokenizer->isFunctionHead(closeParen, ";");
if (eq && Token::simpleMatch(eq->tokAt(-2), "= default ;")) {
func->isDefault(true);
return;
}
@ -2711,10 +2710,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, ") noexcept| = default ;") ||
Token::Match(closeParen, ") . const| %type% &| = default ;") ||
(Token::simpleMatch(closeParen, ") noexcept (") &&
Token::simpleMatch(closeParen->linkAt(2), ") = default ;"))) {
const Token *eq = mTokenizer->isFunctionHead(closeParen, ";");
if (eq && Token::simpleMatch(eq->tokAt(-2), "= default ;")) {
func->isDefault(true);
return;
}

View File

@ -4613,7 +4613,7 @@ private:
void symboldatabase86() {
GET_SYMBOL_DB("class C { auto operator=(const C&) -> C&; };\n"
"auto C::operator=(const C&) -> C& = default;");
"auto C::operator=(const C&) -> C& = default;");
ASSERT(db->scopeList.size() == 2);
ASSERT(db->scopeList.back().functionList.size() == 1);
ASSERT(db->scopeList.back().functionList.front().isDefault() == true);