Remove some redundant semicolons - part 2
This commit is contained in:
parent
ff1cb241a8
commit
c2ddb67316
|
@ -5286,6 +5286,9 @@ bool Tokenizer::simplifyQuestionMark()
|
|||
int ind = 0;
|
||||
for (const Token *endTok = semicolon; endTok; endTok = endTok->next()) {
|
||||
if (endTok->str() == ";") {
|
||||
//we can remove the semicolon if after it there's at least another token
|
||||
if (endTok->next())
|
||||
endTok = endTok->next();
|
||||
Token::eraseTokens(semicolon->previous(), endTok);
|
||||
ret = true;
|
||||
break;
|
||||
|
@ -6708,7 +6711,7 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign
|
|||
if (Token::Match((*tok2)->tokAt(-7), "%type% * %var% ; %var% = & %var% ;") &&
|
||||
(*tok2)->strAt(-5) == (*tok2)->strAt(-3)) {
|
||||
(*tok2) = (*tok2)->tokAt(-4);
|
||||
Token::eraseTokens((*tok2), (*tok2)->tokAt(5));
|
||||
Token::eraseTokens((*tok2), (*tok2)->tokAt(6));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -7039,7 +7042,7 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign
|
|||
if (indentlevel == indentlevel3 && Token::Match(tok3->next(), "%varid% ++|--", varid) && MathLib::isInt(value)) {
|
||||
const std::string op(tok3->strAt(2));
|
||||
if (Token::Match(tok3, "[{};] %any% %any% ;")) {
|
||||
Token::eraseTokens(tok3, tok3->tokAt(3));
|
||||
Token::eraseTokens(tok3, tok3->tokAt(4));
|
||||
} else {
|
||||
tok3 = tok3->next();
|
||||
tok3->str(value);
|
||||
|
@ -7060,7 +7063,7 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign
|
|||
(*tok2)->tokAt(2)->str(value);
|
||||
(*tok2)->tokAt(2)->varId(valueVarId);
|
||||
if (Token::Match(tok3, "[;{}] %any% %any% ;")) {
|
||||
Token::eraseTokens(tok3, tok3->tokAt(3));
|
||||
Token::eraseTokens(tok3, tok3->tokAt(4));
|
||||
} else {
|
||||
tok3->deleteNext();
|
||||
tok3->next()->str(value);
|
||||
|
|
|
@ -1174,7 +1174,7 @@ private:
|
|||
"}\n";
|
||||
|
||||
ASSERT_EQUALS(
|
||||
"void foo ( ) { int i ; i = 23 ; ; abc [ 23 ] = 0 ; }",
|
||||
"void foo ( ) { int i ; i = 23 ; abc [ 23 ] = 0 ; }",
|
||||
simplifyKnownVariables(code));
|
||||
}
|
||||
|
||||
|
@ -4155,7 +4155,7 @@ private:
|
|||
std::ostringstream ostr;
|
||||
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
|
||||
ostr << " " << tok->str();
|
||||
ASSERT_EQUALS(" void f ( ) { } void g ( ) { }", ostr.str());
|
||||
ASSERT_EQUALS(" void f ( ) { ; } void g ( ) { ; }", ostr.str());
|
||||
}
|
||||
|
||||
void simplify_constants2() {
|
||||
|
|
Loading…
Reference in New Issue