summaryrefslogtreecommitdiffstats
path: root/test/Analysis/idempotent-operations-limited-loops.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/idempotent-operations-limited-loops.c')
-rw-r--r--test/Analysis/idempotent-operations-limited-loops.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/Analysis/idempotent-operations-limited-loops.c b/test/Analysis/idempotent-operations-limited-loops.c
new file mode 100644
index 0000000..e4c34cd
--- /dev/null
+++ b/test/Analysis/idempotent-operations-limited-loops.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -analyzer-max-loop 3 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -analyzer-max-loop 4 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps %s -verify
+
+void always_warning() { int *p = 0; *p = 0xDEADBEEF; } // expected-warning{{Dereference of null pointer (loaded from variable 'p')}}
+
+// This test case previously caused a bogus idempotent operation warning
+// due to us not properly culling warnings due to incomplete analysis of loops.
+int pr8403()
+{
+ int i;
+ for(i=0; i<10; i++)
+ {
+ int j;
+ for(j=0; j+1<i; j++)
+ {
+ }
+ }
+ return 0;
+}
+
OpenPOWER on IntegriCloud