Added checking of (x == x) and (x != x) to IdempotentOperationChecker and updated test cases flagged by it.
llvm-svn: 112313
diff --git a/clang/lib/Checker/IdempotentOperationChecker.cpp b/clang/lib/Checker/IdempotentOperationChecker.cpp
index 35fb83e..8a9e333 100644
--- a/clang/lib/Checker/IdempotentOperationChecker.cpp
+++ b/clang/lib/Checker/IdempotentOperationChecker.cpp
@@ -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;
diff --git a/clang/test/Analysis/misc-ps.m b/clang/test/Analysis/misc-ps.m
index 1aa80bd..6aac74b 100644
--- a/clang/test/Analysis/misc-ps.m
+++ b/clang/test/Analysis/misc-ps.m
@@ -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
   }
diff --git a/clang/test/Analysis/null-deref-ps.c b/clang/test/Analysis/null-deref-ps.c
index d0e4f61..8daa845 100644
--- a/clang/test/Analysis/null-deref-ps.c
+++ b/clang/test/Analysis/null-deref-ps.c
@@ -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
   }