diff --git a/checkmemoryleak.cpp b/checkmemoryleak.cpp index 491ad2d6f..7f89e53d3 100644 --- a/checkmemoryleak.cpp +++ b/checkmemoryleak.cpp @@ -785,6 +785,17 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok) { erase( tok2, tok2->tokAt(4) ); done = false; + } + + // Reduce "loop { assign|dealloc|use ; alloc ; if break ; }" to "assign|dealloc|use ; alloc ;" + if ( TOKEN::Match( tok2->next(), "loop { assign|dealloc|use ; alloc ; if break|continue ; }" ) ) + { + // erase "loop {" + erase( tok2, tok2->tokAt(3) ); + // erase "if break|continue ; }" + tok2 = tok2->next()->next()->next()->next(); + erase( tok2, tok2->tokAt(5) ); + done = false; } // Reduce "if(true) X ;" => "X ;" diff --git a/testmemleak.cpp b/testmemleak.cpp index c43527c08..318eaec20 100644 --- a/testmemleak.cpp +++ b/testmemleak.cpp @@ -97,7 +97,7 @@ private: TEST_CASE( forwhile5 ); TEST_CASE( forwhile6 ); TEST_CASE( forwhile7 ); - // TODO TEST_CASE( forwhile8 ); // Bug 2429936 + TEST_CASE( forwhile8 ); // Bug 2429936 TEST_CASE( dowhile1 );