[analyzer] Don't reinitialize static globals more than once along a path
This patch makes sure that we do not reinitialize static globals when
the function is called more than once along a path. The motivation is
code with initialization patterns that rely on 2 static variables, where
one of them has an initializer while the other does not. Currently, we
reset the static variables with initializers on every visit to the
function along a path.
llvm-svn: 174676
diff --git a/clang/test/Analysis/global_region_invalidation.mm b/clang/test/Analysis/global_region_invalidation.mm
new file mode 100644
index 0000000..0d7f172
--- /dev/null
+++ b/clang/test/Analysis/global_region_invalidation.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+void use(int);
+id foo(int x) {
+ if (x)
+ return 0;
+ static id p = foo(1);
+ clang_analyzer_eval(p == 0); // expected-warning{{TRUE}}
+ return p;
+}
\ No newline at end of file