diff options
Diffstat (limited to 'test/Analysis/global_region_invalidation.mm')
-rw-r--r-- | test/Analysis/global_region_invalidation.mm | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/test/Analysis/global_region_invalidation.mm b/test/Analysis/global_region_invalidation.mm index be337edab1..f853470a5f 100644 --- a/test/Analysis/global_region_invalidation.mm +++ b/test/Analysis/global_region_invalidation.mm @@ -11,9 +11,35 @@ id foo(int x) { return p; } -const int &globalInt = 42; +const int &globalIntRef = 42; -void testGlobal() { +void testGlobalRef() { // FIXME: Should be TRUE, but should at least not crash. + clang_analyzer_eval(globalIntRef == 42); // expected-warning{{UNKNOWN}} +} + +extern int globalInt; +extern void invalidateGlobals(); + +void testGlobalInvalidation() { + if (globalInt != 42) + return; + clang_analyzer_eval(globalInt == 42); // expected-warning{{TRUE}} + + invalidateGlobals(); clang_analyzer_eval(globalInt == 42); // expected-warning{{UNKNOWN}} } + + +//--------------------------------- +// False negatives +//--------------------------------- + +void testGlobalInvalidationWithDirectBinding() { + globalInt = 42; + clang_analyzer_eval(globalInt == 42); // expected-warning{{TRUE}} + + invalidateGlobals(); + // FIXME: Should be UNKNOWN. + clang_analyzer_eval(globalInt == 42); // expected-warning{{TRUE}} +} |