]> granicus.if.org Git - clang/commitdiff
Added checking of (x == x) and (x != x) to IdempotentOperationChecker and updated...
authorTom Care <tom.care@uqconnect.edu.au>
Fri, 27 Aug 2010 22:50:47 +0000 (22:50 +0000)
committerTom Care <tom.care@uqconnect.edu.au>
Fri, 27 Aug 2010 22:50:47 +0000 (22:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112313 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Checker/IdempotentOperationChecker.cpp
test/Analysis/misc-ps.m
test/Analysis/null-deref-ps.c

index 35fb83e877570bdb83891dc12def471b28aa4677..8a9e333ce5c5b5aa1298991698e9163496c147b2 100644 (file)
@@ -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;
index 1aa80bd89fe8c1577cf23c591713f845d0a78008..6aac74b1091b141e619d8030433023540b962f84 100644 (file)
@@ -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
   }
index d0e4f61521a086903d14f9ad67fbb8dff3098af2..8daa84506818998907f67a8ce4feb5846d5850ad 100644 (file)
@@ -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
   }