From 9a47b7110e370bb6c3918a3b0b0c27836cd69245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 1 Sep 2009 20:02:28 +0200 Subject: [PATCH] memory leaks: fixed todo testcases to find more memory leaks --- src/checkmemoryleak.cpp | 4 ++-- test/testmemleak.cpp | 20 +------------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index 865af7f00..cb5ae283e 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -1222,8 +1222,8 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all) done = false; } - // Delete first if in .. "if { dealloc|assign|use ; return ; } if return ;" - else if (Token::Match(tok2, "[;{}] if { dealloc|assign|use ; return ; } if return ;")) + // Delete "if { dealloc|assign|use ; return ; }" + else if (Token::Match(tok2, "[;{}] if { dealloc|assign|use ; return ; }")) { Token::eraseTokens(tok2, tok2->tokAt(8)); done = false; diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index f7e400b24..934aac221 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -452,15 +452,7 @@ private: ASSERT_EQUALS("; if(var) xxx ;", simplifycode("; if(!var) ; else xxx ;")); ASSERT_EQUALS("; if(!var) xxx ;", simplifycode("; if(var) ; else xxx ;")); ASSERT_EQUALS("; ifv xxx ;", simplifycode("; ifv ; else xxx ;")); - - { - const char code1[] = "; alloc ; if { dealloc ; return ; }"; - ASSERT_EQUALS(code1, simplifycode(code1)); - ASSERT_EQUALS("; alloc ;", simplifycode(code1, true)); - - const char code2[] = "; alloc ; if { dealloc ; return ; } else { return ; }"; - ASSERT_EQUALS("; alloc ; if return ;", simplifycode(code2)); - } + ASSERT_EQUALS("; alloc ;", simplifycode("; alloc; if { dealloc; return; }")); // switch.. @@ -471,8 +463,6 @@ private: ASSERT_EQUALS("; loop alloc ;", simplifycode("; loop { alloc ; }")); ASSERT_EQUALS("; alloc ; alloc ;", simplifycode("; alloc ; do { alloc ; } loop ;")); - // return.. - // callfunc.. ASSERT_EQUALS("; callfunc ;", simplifycode(";callfunc;", false)); ASSERT_EQUALS(";", simplifycode(";callfunc;", true)); @@ -485,17 +475,9 @@ private: TODO_ASSERT_EQUALS(";", simplifycode("; alloc ; ifv { exit; }", false)); TODO_ASSERT_EQUALS("; alloc ;", simplifycode("; alloc ; ifv { exit; }", true)); - ASSERT_EQUALS("; alloc ; if { dealloc ; return ; }", simplifycode("; alloc; if { dealloc; return; }")); - TODO_ASSERT_EQUALS("; alloc ;", simplifycode("; alloc; if { dealloc; return; }")); ASSERT_EQUALS("; alloc ; if return ; return ;", simplifycode(";alloc;if{return;}return;")); TODO_ASSERT_EQUALS("; alloc ; return ;", simplifycode(";alloc;if{return;}return;")); - - { - const char code[] = "; alloc ; if { dealloc ; return ; } dealloc ;"; - ASSERT_EQUALS(code, simplifycode(code)); - TODO_ASSERT_EQUALS("; alloc ; dealloc ;", simplifycode(code)); - } }