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() == "&&") {
function.hasRvalRefQualifier(true);
tok = tok->next();
} else if (Token::simpleMatch(tok, "noexcept (")) {
function.isNoExcept(tok->strAt(2) != "false");
tok = tok->linkAt(1)->next();
} else if (tok->str() == "noexcept") {
function.isNoExcept(!Token::simpleMatch(tok->next(), "( false )"));
tok = tok->next();
if (tok->str() == "(")
tok = tok->link()->next();
} else if (Token::simpleMatch(tok, "throw (")) {
function.isThrow(true);
if (tok->strAt(2) != ")")
@ -476,26 +478,6 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
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)
else if (Token::Match(end, ") %any% ;")) {
tok = end->tokAt(2);

View File

@ -64,7 +64,7 @@ const Token * Tokenizer::isFunctionHead(const Token *tok, const std::string &end
tok = tok->next();
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();
while (tok->isName())
tok = tok->next();