From 45d71a271554ff183629e7451ada8f440a20654c Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 21 Feb 2014 00:18:31 +0000 Subject: [analyzer] Fix a bug in IdenticalExprChecker concerning while loops. Somehow both Daniel and I missed the fact that while loops are only identical if they have identical bodies. Patch by Daniel Fahlgren! llvm-svn: 201829 --- clang/test/Analysis/identical-expressions.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'clang/test/Analysis/identical-expressions.cpp') diff --git a/clang/test/Analysis/identical-expressions.cpp b/clang/test/Analysis/identical-expressions.cpp index 950cdd93ff4..e1f51af7c6f 100644 --- a/clang/test/Analysis/identical-expressions.cpp +++ b/clang/test/Analysis/identical-expressions.cpp @@ -1287,6 +1287,17 @@ void test_identical_branches_while(bool b) { } } +void test_identical_branches_while_2(bool b) { + int i = 10; + if (b) { // no-warning + while (func()) + i--; + } else { + while (func()) + i++; + } +} + void test_identical_branches_do_while(bool b) { int i = 10; if (b) { // expected-warning {{true and false branches are identical}} -- cgit v1.2.3