[cfe-commits] r112313 - in /cfe/trunk: lib/Checker/IdempotentOperationChecker.cpp test/Analysis/misc-ps.m test/Analysis/null-deref-ps.c

Tom Care tcare at apple.com
Fri Aug 27 15:50:47 PDT 2010


Author: tcare
Date: Fri Aug 27 17:50:47 2010
New Revision: 112313

URL: http://llvm.org/viewvc/llvm-project?rev=112313&view=rev
Log:
Added checking of (x == x) and (x != x) to IdempotentOperationChecker and updated test cases flagged by it.

Modified:
    cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp
    cfe/trunk/test/Analysis/misc-ps.m
    cfe/trunk/test/Analysis/null-deref-ps.c

Modified: cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp?rev=112313&r1=112312&r2=112313&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp (original)
+++ cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp Fri Aug 27 17:50:47 2010
@@ -210,6 +210,8 @@
   case BO_Xor:
   case BO_LOr:
   case BO_LAnd:
+  case BO_EQ:
+  case BO_NE:
     if (LHSVal != RHSVal || LHSContainsFalsePositive
         || RHSContainsFalsePositive)
       break;

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=112313&r1=112312&r2=112313&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Fri Aug 27 17:50:47 2010
@@ -407,14 +407,14 @@
   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
   }

Modified: cfe/trunk/test/Analysis/null-deref-ps.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/null-deref-ps.c?rev=112313&r1=112312&r2=112313&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/null-deref-ps.c (original)
+++ cfe/trunk/test/Analysis/null-deref-ps.c Fri Aug 27 17:50:47 2010
@@ -66,7 +66,7 @@
   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
   }





More information about the cfe-commits mailing list