Merge pull request #577 from Dmitry-Me/properSimplifyDeleteWithComma
Proper simplify delete a,b
This commit is contained in:
commit
c70db2a751
|
@ -8726,9 +8726,8 @@ void Tokenizer::simplifyComma()
|
||||||
|
|
||||||
if (Token::Match(tok->tokAt(-2), "delete %name% , %name% ;") &&
|
if (Token::Match(tok->tokAt(-2), "delete %name% , %name% ;") &&
|
||||||
tok->next()->varId() != 0) {
|
tok->next()->varId() != 0) {
|
||||||
// Handle "delete a, b;"
|
// Handle "delete a, b;" - convert to delete a; b;
|
||||||
tok->str(";");
|
tok->str(";");
|
||||||
tok->insertToken("delete");
|
|
||||||
} else if (!inReturn && tok->tokAt(-2)) {
|
} else if (!inReturn && 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()) {
|
||||||
|
|
|
@ -1796,7 +1796,17 @@ private:
|
||||||
" char *a, *b;\n"
|
" char *a, *b;\n"
|
||||||
" delete a, b;\n"
|
" delete a, b;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
ASSERT_EQUALS("void foo ( ) { char * a ; char * b ; delete a ; delete b ; }", tok(code));
|
ASSERT_EQUALS("void foo ( ) { char * a ; char * b ; delete a ; b ; }", tok(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const char code[] = "void foo()\n"
|
||||||
|
"{\n"
|
||||||
|
" char *a, *b;\n"
|
||||||
|
" if (x) \n"
|
||||||
|
" delete a, b;\n"
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQUALS("void foo ( ) { char * a ; char * b ; if ( x ) { delete a ; b ; } }", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue