diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-02-13 03:11:06 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-02-13 03:11:06 +0000 |
commit | 38f68ef19cb51d5876e9025b5fceb44b33ec9ed7 (patch) | |
tree | 068ddb9e8bdda120632d421a06ddc96d7bdc13cc /test/Analysis/global-region-invalidation.c | |
parent | 04870edbea6cf88412c8c9c1eba65f7fc1fa12d9 (diff) |
[analyzer] Use Clang's evaluation for global constants and default arguments.
Previously, we were handling only simple integer constants for globals and
the smattering of implicitly-valued expressions handled by Environment for
default arguments. Now, we can use any integer constant expression that
Clang can evaluate, in addition to everything we handled before.
PR15094 / <rdar://problem/12830437>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175026 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/global-region-invalidation.c')
-rw-r--r-- | test/Analysis/global-region-invalidation.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/test/Analysis/global-region-invalidation.c b/test/Analysis/global-region-invalidation.c index 113e6ae363..77de9dd326 100644 --- a/test/Analysis/global-region-invalidation.c +++ b/test/Analysis/global-region-invalidation.c @@ -67,15 +67,29 @@ int constIntGlob() { return 3 / *m; // expected-warning {{Division by zero}} } -extern const int x; +extern const int y; int constIntGlobExtern() { - if (x == 0) { + if (y == 0) { foo(); - return 5 / x; // expected-warning {{Division by zero}} + return 5 / y; // expected-warning {{Division by zero}} } return 0; } +static void * const ptr = 0; +void constPtrGlob() { + clang_analyzer_eval(ptr == 0); // expected-warning{{TRUE}} + foo(); + clang_analyzer_eval(ptr == 0); // expected-warning{{TRUE}} +} + +static const int x2 = x; +void constIntGlob2() { + clang_analyzer_eval(x2 == 0); // expected-warning{{TRUE}} + foo(); + clang_analyzer_eval(x2 == 0); // expected-warning{{TRUE}} +} + void testAnalyzerEvalIsPure() { extern int someGlobal; if (someGlobal == 0) { |