From 15a185f1e0f4d72255f482ce9cac7ef361a3778d Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Tue, 19 Mar 2013 22:10:44 +0000 Subject: [PATCH] [analyzer] Add a test case for diagnostic suppression on a graph with cycles. (see previous commit) llvm-svn: 177449 --- .../diagnostics/shortest-path-suppression.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 clang/test/Analysis/diagnostics/shortest-path-suppression.c diff --git a/clang/test/Analysis/diagnostics/shortest-path-suppression.c b/clang/test/Analysis/diagnostics/shortest-path-suppression.c new file mode 100644 index 000000000000..4f648b986b25 --- /dev/null +++ b/clang/test/Analysis/diagnostics/shortest-path-suppression.c @@ -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; +}