From ae0252dc9145b1cac6454bc5612aabdeb9770511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 2 Aug 2010 21:59:47 +0200 Subject: [PATCH] memory leaks: simplify 'callfunc ; ;' --- lib/checkmemoryleak.cpp | 3 ++- test/testmemleak.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index e0129af71..7dde64e84 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1465,7 +1465,8 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok) // reduce "; callfunc ; %var%" for (Token *tok2 = tok; tok2; tok2 = tok2->next()) { - if (Token::Match(tok2, ";|{|} callfunc ; %type%")) + if (Token::Match(tok2, ";|{|} callfunc ; %type%") || + Token::Match(tok2, ";|{|} callfunc ; ;")) tok2->deleteNext(); } diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index f71cd1545..b25b3a6ea 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -708,6 +708,7 @@ private: // callfunc.. ASSERT_EQUALS("; callfunc ;", simplifycode(";callfunc;")); + ASSERT_EQUALS(";", simplifycode(";callfunc;;")); ASSERT_EQUALS("while1 { dealloc ; alloc ; } return ; }", simplifycode("while1 { dealloc ; alloc ; } callfunc ; return ; }")); // exit..