Improved IdempotentOperationChecker false positives and false negatives.
- Unfinished analysis may still report valid warnings if the path was completely analyzed
- New 'CanVary' heuristic to recursively determine if a subexpression has a varying element
- Updated test cases, including one known bug
- Exposed GRCoreEngine through GRExprEngine
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110970 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/idempotent-operations.c b/test/Analysis/idempotent-operations.c
index 2543b1a..23401e8 100644
--- a/test/Analysis/idempotent-operations.c
+++ b/test/Analysis/idempotent-operations.c
@@ -53,20 +53,33 @@
}
void floats(float x) {
- test_f(x * 1.0); // no-warning
+ test_f(x * 1.0); // no-warning
test_f(x * 1.0F); // no-warning
}
-// Ensure that we don't report false poitives on complex loops
+// Ensure that we don't report false poitives in complex loops
void bailout() {
- int unused, result = 4;
- int numbers[5] = { 0, 32, 'x', 128, 255 };
+ int unused = 0, result = 4;
+ result = result; // expected-warning {{Assigned value is always the same as the existing value}}
- for (int bg = 0; bg < 5; bg ++) {
- result += numbers[bg]; // no-warning
+ for (unsigned bg = 0; bg < 1024; bg ++) {
+ result = bg * result; // no-warning
for (int i = 0; i < 256; i++) {
- unused = i;
+ unused *= i; // no-warning
}
}
}
+
+// False positive tests
+
+unsigned false1() {
+ return (5 - 2 - 3); // no-warning
+}
+
+enum testenum { enum1 = 0, enum2 };
+unsigned false2() {
+ return enum1; // no-warning
+}
+
+extern unsigned foo();