[analyzer] Add a test case for diagnostic suppression on a graph with cycles.
authorJordan Rose <jordan_rose@apple.com>
Tue, 19 Mar 2013 22:10:44 +0000 (22:10 +0000)
committerJordan Rose <jordan_rose@apple.com>
Tue, 19 Mar 2013 22:10:44 +0000 (22:10 +0000)
(see previous commit)

llvm-svn: 177449

clang/test/Analysis/diagnostics/shortest-path-suppression.c [new file with mode: 0644]

diff --git a/clang/test/Analysis/diagnostics/shortest-path-suppression.c b/clang/test/Analysis/diagnostics/shortest-path-suppression.c
new file mode 100644 (file)
index 0000000..4f648b9
--- /dev/null
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config suppress-null-return-paths=true -analyzer-output=text -verify %s
+// expected-no-diagnostics
+
+int *returnNull() { return 0; }
+int coin();
+
+// Use a float parameter to ensure that the value is unknown. This will create
+// a cycle in the generated ExplodedGraph.
+void testCycle(float i) {
+  int *x = returnNull();
+  int y; 
+  while (i > 0) {
+    x = returnNull();
+    y = 2;
+    i -= 1;
+  }
+  *x = 1; // no-warning
+  y += 1;
+}