Refactorizations:

- Removed some duplicate nullpointer checks
- Simplified tok->link() on '<' usage.
This commit is contained in:
PKEuS 2014-05-18 17:04:52 +02:00
parent 65916e027c
commit b162560755
1 changed files with 23 additions and 28 deletions

View File

@ -8613,11 +8613,8 @@ void Tokenizer::simplifyComma()
} }
// Skip unhandled template specifiers.. // Skip unhandled template specifiers..
if (Token::Match(tok, "%var% <")) { if (tok->link() && tok->str() == "<")
Token* tok2 = tok->next()->link(); tok = tok->link();
if (tok2)
tok = tok2;
}
if (!tok->next() || tok->str() != ",") if (!tok->next() || tok->str() != ",")
continue; continue;
@ -8629,13 +8626,12 @@ void Tokenizer::simplifyComma()
tok->str(";"); tok->str(";");
} }
if (tok->previous() && tok->tokAt(-2)) {
if (Token::Match(tok->tokAt(-2), "delete %var% , %var% ;") && if (Token::Match(tok->tokAt(-2), "delete %var% , %var% ;") &&
tok->next()->varId() != 0) { tok->next()->varId() != 0) {
// Handle "delete a, b;" // Handle "delete a, b;"
tok->str(";"); tok->str(";");
tok->insertToken("delete"); tok->insertToken("delete");
} else { } else if (tok->tokAt(-2)) {
bool replace = false; bool replace = false;
for (Token *tok2 = tok->previous(); tok2; tok2 = tok2->previous()) { for (Token *tok2 = tok->previous(); tok2; tok2 = tok2->previous()) {
if (tok2->str() == "=") { if (tok2->str() == "=") {
@ -8652,7 +8648,6 @@ void Tokenizer::simplifyComma()
} }
} }
} }
}
bool inReturn = false; bool inReturn = false;
Token *startFrom = nullptr; // "[;{}]" token before "return" Token *startFrom = nullptr; // "[;{}]" token before "return"
@ -9773,7 +9768,7 @@ void Tokenizer::simplifyMicrosoftStringFunctions()
tok->deleteNext(); tok->deleteNext();
tok->deleteThis(); tok->deleteThis();
tok->deleteNext(); tok->deleteNext();
while (tok->next() && Token::Match(tok->next(), "_T ( %char%|%str% )")) { while (Token::Match(tok->next(), "_T ( %char%|%str% )")) {
tok->next()->deleteNext(); tok->next()->deleteNext();
tok->next()->deleteThis(); tok->next()->deleteThis();
tok->next()->deleteNext(); tok->next()->deleteNext();
@ -9886,7 +9881,7 @@ void Tokenizer::simplifyMicrosoftStringFunctions()
tok->deleteThis(); tok->deleteThis();
tok->deleteNext(); tok->deleteNext();
tok->isLong(true); tok->isLong(true);
while (tok->next() && Token::Match(tok->next(), "_T ( %char%|%str% )")) { while (Token::Match(tok->next(), "_T ( %char%|%str% )")) {
tok->next()->deleteNext(); tok->next()->deleteNext();
tok->next()->deleteThis(); tok->next()->deleteThis();
tok->next()->deleteNext(); tok->next()->deleteNext();