summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-04-15 20:39:41 +0000
committerJordan Rose <jordan_rose@apple.com>2013-04-15 20:39:41 +0000
commit577749a337456444c1030d46eb9c7baa8126ac00 (patch)
tree0f74d6e3f7ea5145866dcbdfdcdf81d0e541d097 /clang/test/Analysis
parentd02adbf03c994c5280c3641d16fce1169ad1ff4e (diff)
downloadbcm5719-llvm-577749a337456444c1030d46eb9c7baa8126ac00.tar.gz
bcm5719-llvm-577749a337456444c1030d46eb9c7baa8126ac00.zip
[analyzer] Properly invalidate global regions on opaque function calls.
This fixes a regression where a call to a function we can't reason about would not actually invalidate global regions that had explicit bindings. void test_that_now_works() { globalInt = 42; clang_analyzer_eval(globalInt == 42); // expected-warning{{TRUE}} invalidateGlobals(); clang_analyzer_eval(globalInt == 42); // expected-warning{{UNKNOWN}} } This has probably been around since the initial "cluster" refactoring of RegionStore, if not longer. <rdar://problem/13464044> llvm-svn: 179553
Diffstat (limited to 'clang/test/Analysis')
-rw-r--r--clang/test/Analysis/global_region_invalidation.mm24
1 files changed, 17 insertions, 7 deletions
diff --git a/clang/test/Analysis/global_region_invalidation.mm b/clang/test/Analysis/global_region_invalidation.mm
index f853470a5fd..5e9f1bcb836 100644
--- a/clang/test/Analysis/global_region_invalidation.mm
+++ b/clang/test/Analysis/global_region_invalidation.mm
@@ -19,27 +19,37 @@ void testGlobalRef() {
}
extern int globalInt;
+extern struct {
+ int value;
+} globalStruct;
extern void invalidateGlobals();
void testGlobalInvalidation() {
+ clang_analyzer_eval(globalInt == 42); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(globalStruct.value == 43); // expected-warning{{UNKNOWN}}
+
if (globalInt != 42)
return;
+ if (globalStruct.value != 43)
+ return;
clang_analyzer_eval(globalInt == 42); // expected-warning{{TRUE}}
+ clang_analyzer_eval(globalStruct.value == 43); // expected-warning{{TRUE}}
invalidateGlobals();
clang_analyzer_eval(globalInt == 42); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(globalStruct.value == 43); // expected-warning{{UNKNOWN}}
}
-
-//---------------------------------
-// False negatives
-//---------------------------------
-
void testGlobalInvalidationWithDirectBinding() {
+ clang_analyzer_eval(globalInt == 42); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(globalStruct.value == 43); // expected-warning{{UNKNOWN}}
+
globalInt = 42;
+ globalStruct.value = 43;
clang_analyzer_eval(globalInt == 42); // expected-warning{{TRUE}}
+ clang_analyzer_eval(globalStruct.value == 43); // expected-warning{{TRUE}}
invalidateGlobals();
- // FIXME: Should be UNKNOWN.
- clang_analyzer_eval(globalInt == 42); // expected-warning{{TRUE}}
+ clang_analyzer_eval(globalInt == 42); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(globalStruct.value == 43); // expected-warning{{UNKNOWN}}
}
OpenPOWER on IntegriCloud