diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index 8f5fb6595..33fdaba98 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -851,6 +851,13 @@ void CheckMemoryLeakClass::simplifycode(Token *tok) done = false; } + // Remove "if { dealloc ; callfunc ; } !!else" + else if (Token::Match(tok2->next(), "if { dealloc|assign|use ; callfunc ; } !!else")) + { + erase(tok2, tok2->tokAt(8)); + done = false; + } + // Reducing if.. else if (_settings._showAll) { diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index b88ef01ab..33a910462 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -189,7 +189,7 @@ private: // Calls to unknown functions.. they may throw exception, quit the program, etc TEST_CASE(unknownFunction1); - // TODO TEST_CASE(unknownFunction2); + TEST_CASE(unknownFunction2); } @@ -1853,7 +1853,7 @@ private: " ThrowException();\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:9] (error) Memory leak: p\n", errout.str()); + ASSERT_EQUALS("[test.cpp:9]: (error) Memory leak: p\n", errout.str()); } };