SymbolDatabase,Tokenizer: Refactor handling of noexcept

This commit is contained in:
Daniel Marjamäki 2016-01-03 08:36:00 +01:00
parent 9dabd17eae
commit 4ff7fa3f3b
2 changed files with 6 additions and 24 deletions

View File

@ -456,9 +456,11 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
} else if (tok->str() == "&&") { } else if (tok->str() == "&&") {
function.hasRvalRefQualifier(true); function.hasRvalRefQualifier(true);
tok = tok->next(); tok = tok->next();
} else if (Token::simpleMatch(tok, "noexcept (")) { } else if (tok->str() == "noexcept") {
function.isNoExcept(tok->strAt(2) != "false"); function.isNoExcept(!Token::simpleMatch(tok->next(), "( false )"));
tok = tok->linkAt(1)->next(); tok = tok->next();
if (tok->str() == "(")
tok = tok->link()->next();
} else if (Token::simpleMatch(tok, "throw (")) { } else if (Token::simpleMatch(tok, "throw (")) {
function.isThrow(true); function.isThrow(true);
if (tok->strAt(2) != ")") if (tok->strAt(2) != ")")
@ -476,26 +478,6 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
scope->addFunction(function); scope->addFunction(function);
} }
// noexcept;
// noexcept = 0;
// const noexcept;
// const noexcept = 0;
else if (Token::Match(end, ") const| noexcept ;|=")) {
function.isNoExcept(true);
if (end->next()->str() == "const")
tok = end->tokAt(3);
else
tok = end->tokAt(2);
if (Token::Match(tok, "= !!default ;")) {
function.isPure(true);
tok = tok->tokAt(2);
}
scope->addFunction(function);
}
// 'const' or unknown macro (#5197) // 'const' or unknown macro (#5197)
else if (Token::Match(end, ") %any% ;")) { else if (Token::Match(end, ") %any% ;")) {
tok = end->tokAt(2); tok = end->tokAt(2);

View File

@ -64,7 +64,7 @@ const Token * Tokenizer::isFunctionHead(const Token *tok, const std::string &end
tok = tok->next(); tok = tok->next();
return (endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr; return (endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr;
} }
if (isCPP() && (Token::Match(tok, ") const| throw|noexcept (") || Token::Match(tok, ") const| &|&&| [;:{=]"))) { if (isCPP() && (Token::Match(tok, ") const| throw|noexcept (") || Token::Match(tok, ") const| &|&&|noexcept| [;:{=]"))) {
tok = tok->next(); tok = tok->next();
while (tok->isName()) while (tok->isName())
tok = tok->next(); tok = tok->next();