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 35fb83e..8a9e333 100644
--- a/lib/Checker/IdempotentOperationChecker.cpp
+++ b/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/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m
index 1aa80bd..6aac74b 100644
--- a/test/Analysis/misc-ps.m
+++ b/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/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c
index d0e4f61..8daa845 100644
--- a/test/Analysis/null-deref-ps.c
+++ b/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
}