From 9cadd7c17afa1aeb1a12f558a3c3bdb7115d4fc2 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sun, 4 Dec 2011 18:56:12 +0100 Subject: [PATCH] Remove some redundant semicolons - part 8 --- lib/tokenize.cpp | 16 ++++++++++++++++ test/testsimplifytokens.cpp | 8 +++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 5992b7a43..d9dd42a6f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -940,6 +940,10 @@ void Tokenizer::simplifyTypedef() tok->deleteThis(); tok->deleteThis(); tok->deleteThis(); + if (tok->next()) + tok->deleteThis(); + //now the next token to process is 'tok', not 'tok->next()'; + goback = true; continue; } else { const std::string pattern("struct " + tok->strAt(2) + " {|:"); @@ -1102,6 +1106,9 @@ void Tokenizer::simplifyTypedef() if (typeName->str() == "void") { unsupportedTypedef(typeDef); tok = deleteInvalidTypedef(typeDef); + if (tok == _tokens) + //now the next token to process is 'tok', not 'tok->next()'; + goback = true; continue; } @@ -1111,6 +1118,9 @@ void Tokenizer::simplifyTypedef() Token::Match(tok->linkAt(offset)->tokAt(-3), ":: * %var% ) (")) { unsupportedTypedef(typeDef); tok = deleteInvalidTypedef(typeDef); + if (tok == _tokens) + //now the next token to process is 'tok', not 'tok->next()'; + goback = true; continue; } @@ -1152,6 +1162,9 @@ void Tokenizer::simplifyTypedef() else { unsupportedTypedef(typeDef); tok = deleteInvalidTypedef(typeDef); + if (tok == _tokens) + //now the next token to process is 'tok', not 'tok->next()'; + goback = true; continue; } } @@ -1289,6 +1302,9 @@ void Tokenizer::simplifyTypedef() else { unsupportedTypedef(typeDef); tok = deleteInvalidTypedef(typeDef); + if (tok == _tokens) + //now the next token to process is 'tok', not 'tok->next()'; + goback = true; continue; } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 0bf3c5752..32f1d97e4 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -3611,10 +3611,8 @@ private: "abc e1;\n" "XYZ e2;"; - const char expected[] = - "; " - "int e1 ; " - "int e2 ;"; + const char expected[] = "int e1 ; " + "int e2 ;"; ASSERT_EQUALS(expected, tok(code, false)); } @@ -4878,7 +4876,7 @@ private: " localEntitiyAddFunc_t f;\n" "}\n"; // The expected result.. - const std::string expected("; void f ( ) { int b ; int * f ; }"); + const std::string expected("void f ( ) { int b ; int * f ; }"); ASSERT_EQUALS(expected, sizeof_(code, false)); // Check for output..