Refactorization: Removed some redundant conditions and an unused syntax check from tokenize.cpp

This commit is contained in:
PKEuS 2015-08-19 19:29:32 +02:00
parent a720153e1e
commit 11be2f79a6
1 changed files with 20 additions and 39 deletions

View File

@ -2215,7 +2215,6 @@ static Token *skipTernaryOp(Token *tok)
Token * Tokenizer::startOfFunction(Token * tok) const Token * Tokenizer::startOfFunction(Token * tok) const
{ {
if (tok && tok->str() == ")") {
tok = tok->next(); tok = tok->next();
while (tok && tok->str() != "{") { while (tok && tok->str() != "{") {
if (isCPP() && Token::Match(tok, "const|volatile")) { if (isCPP() && Token::Match(tok, "const|volatile")) {
@ -2241,9 +2240,6 @@ Token * Tokenizer::startOfFunction(Token * tok) const
return tok; return tok;
} }
return nullptr;
}
const Token * Tokenizer::startOfExecutableScope(const Token * tok) const Token * Tokenizer::startOfExecutableScope(const Token * tok)
{ {
if (tok && tok->str() == ")") { if (tok && tok->str() == ")") {
@ -2359,12 +2355,6 @@ void Tokenizer::simplifyTemplates()
if (isC()) if (isC())
return; return;
for (const Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->str()[0] == '=' && tok->str().length() > 2) {
std::cout << "BAD TOKEN" << std::endl;
}
}
for (Token *tok = list.front(); tok; tok = tok->next()) { for (Token *tok = list.front(); tok; tok = tok->next()) {
// #2648 - simple fix for sizeof used as template parameter // #2648 - simple fix for sizeof used as template parameter
// TODO: this is a bit hardcoded. make a bit more generic // TODO: this is a bit hardcoded. make a bit more generic
@ -3096,12 +3086,6 @@ bool Tokenizer::simplifySizeof()
if (tok->str() != "sizeof") if (tok->str() != "sizeof")
continue; continue;
if (!tok->next())
break;
if (tok->strAt(1) == "sizeof")
continue;
if (Token::simpleMatch(tok->next(), ". . .")) { if (Token::simpleMatch(tok->next(), ". . .")) {
tok->deleteNext(3); tok->deleteNext(3);
} }
@ -4202,10 +4186,7 @@ bool Tokenizer::removeRedundantConditions()
bool ret = false; bool ret = false;
for (Token *tok = list.front(); tok; tok = tok->next()) { for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->str() != "if") if (!Token::Match(tok, "if ( %bool% ) {"))
continue;
if (!Token::Match(tok->next(), "( %bool% ) {"))
continue; continue;
// Find matching else // Find matching else