summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-10-18 23:36:05 +0000
committerTed Kremenek <kremenek@apple.com>2010-10-18 23:36:05 +0000
commitda8a79ac8d25860f200079bbc2cbf4f199dfe5ab (patch)
tree066f8aac8604436b63f1a9009b123b8fbbf067b3 /clang/test
parent1c6fd774f7a96d85697a8658838a2ec136c49d63 (diff)
downloadbcm5719-llvm-da8a79ac8d25860f200079bbc2cbf4f199dfe5ab.tar.gz
bcm5719-llvm-da8a79ac8d25860f200079bbc2cbf4f199dfe5ab.zip
"Fix" bogus idempotent operations warning due to loop unrolling not unrolling enough loops to show that an invariant
doesn't hold. This fix is to increase the loop unrolling count to 4, which experiments show doesn't typically impact analysis time. The real fix is to modify the IdempotentOperationsChecker to suppress warnings where an analysis point could be preceded by a point where we gave up due to loop unrolling. llvm-svn: 116769
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Analysis/idempotent-operations-limited-loops.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/test/Analysis/idempotent-operations-limited-loops.c b/clang/test/Analysis/idempotent-operations-limited-loops.c
new file mode 100644
index 00000000000..e3043ee014a
--- /dev/null
+++ b/clang/test/Analysis/idempotent-operations-limited-loops.c
@@ -0,0 +1,29 @@
+void always_warning() { int *p = 0; *p = 0xDEADBEEF; }
+
+// FIXME: False positive due to loop unrolling. This should be fixed.
+
+int pr8403()
+{
+ int i;
+ for(i=0; i<10; i++)
+ {
+ int j;
+ for(j=0; j+1<i; j++)
+ {
+ }
+ }
+ return 0;
+}
+
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-check-idempotent-operations -analyzer-max-loop 3 %s 2>&1 | FileCheck --check-prefix=Loops3 %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-check-idempotent-operations -analyzer-max-loop 4 %s 2>&1 | FileCheck --check-prefix=Loops4 %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-check-idempotent-operations %s 2>&1 | FileCheck --check-prefix=LoopsDefault %s
+
+// CHECK-Loops3: :1:37: warning: Dereference of null pointer
+// CHECK-Loops3: :11:27: warning: The left operand to '+' is always 0
+// CHECK-Loops3: 2 warnings generated
+// CHECK-Loops4: :1:37: warning: Dereference of null pointer
+// CHECK-Loops4: 1 warning generated.
+// CHECK-LoopsDefault: :1:37: warning: Dereference of null pointer
+// CHECK-LoopsDefault: 1 warning generated.
+
OpenPOWER on IntegriCloud