From: Tom Care Date: Fri, 27 Aug 2010 22:50:47 +0000 (+0000) Subject: Added checking of (x == x) and (x != x) to IdempotentOperationChecker and updated... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9edd4d0f73b81baaa7153982bf716949a5b1b926;p=clang Added checking of (x == x) and (x != x) to IdempotentOperationChecker and updated test cases flagged by it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112313 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Checker/IdempotentOperationChecker.cpp b/lib/Checker/IdempotentOperationChecker.cpp index 35fb83e877..8a9e333ce5 100644 --- a/lib/Checker/IdempotentOperationChecker.cpp +++ b/lib/Checker/IdempotentOperationChecker.cpp @@ -210,6 +210,8 @@ void IdempotentOperationChecker::PreVisitBinaryOperator( case BO_Xor: case BO_LOr: case BO_LAnd: + case BO_EQ: + case BO_NE: if (LHSVal != RHSVal || LHSContainsFalsePositive || RHSContainsFalsePositive) break; diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 1aa80bd89f..6aac74b109 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -407,14 +407,14 @@ void test_trivial_symbolic_comparison(int *x) { int test_trivial_symbolic_comparison_aux(); int a = test_trivial_symbolic_comparison_aux(); int b = a; - if (a != b) { + if (a != b) { // expected-warning{{Both operands to '!=' always have the same value}} int *p = 0; *p = 0xDEADBEEF; // no-warning } a = a == 1; b = b == 1; - if (a != b) { + if (a != b) { // expected-warning{{Both operands to '!=' always have the same value}} int *p = 0; *p = 0xDEADBEEF; // no-warning } diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c index d0e4f61521..8daa845068 100644 --- a/test/Analysis/null-deref-ps.c +++ b/test/Analysis/null-deref-ps.c @@ -66,7 +66,7 @@ int f4_b() { short *p = x; // expected-warning{{incompatible integer to pointer conversion}} // The following branch should be infeasible. - if (!(p == &array[0])) { + if (!(p == &array[0])) { // expected-warning{{Both operands to '==' always have the same value}} p = 0; *p = 1; // no-warning }