diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-08-03 23:09:01 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-08-03 23:09:01 +0000 |
commit | 685379965c1b105ce89cf4f6c60810932b7f4d0d (patch) | |
tree | 4171a792c30f6524a7e39f2adb56057778edafb8 /test/Analysis/inlining/path-notes.c | |
parent | b0e1badc2a9b8275b48dfb15c6907a282b949b02 (diff) |
[analyzer] When a symbol is null, we should track its constraints.
Because of this, we would previously emit NO path notes when a parameter
is constrained to null (because there are no stores). Now we show where we
made the assumption, which is much more useful.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161280 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/inlining/path-notes.c')
-rw-r--r-- | test/Analysis/inlining/path-notes.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/test/Analysis/inlining/path-notes.c b/test/Analysis/inlining/path-notes.c index 1db3c5aab8..53bc4249b7 100644 --- a/test/Analysis/inlining/path-notes.c +++ b/test/Analysis/inlining/path-notes.c @@ -11,4 +11,46 @@ void testZero(int *a) { // expected-note@-2 {{Returning from 'zero'}} *a = 1; // expected-warning{{Dereference of null pointer}} // expected-note@-1 {{Dereference of null pointer (loaded from variable 'a')}} -}
\ No newline at end of file +} + + +void check(int *p) { + if (p) { + // expected-note@-1 + {{Assuming 'p' is null}} + // expected-note@-2 + {{Assuming pointer value is null}} + // expected-note@-3 + {{Taking false branch}} + return; + } + return; +} + +void testCheck(int *a) { + check(a); + // expected-note@-1 {{Calling 'check'}} + // expected-note@-2 {{Returning from 'check'}} + *a = 1; // expected-warning{{Dereference of null pointer}} + // expected-note@-1 {{Dereference of null pointer (loaded from variable 'a')}} +} + + +int *getPointer(); + +void testInitCheck() { + int *a = getPointer(); + // expected-note@-1 {{Variable 'a' initialized here}} + check(a); + // expected-note@-1 {{Calling 'check'}} + // expected-note@-2 {{Returning from 'check'}} + *a = 1; // expected-warning{{Dereference of null pointer}} + // expected-note@-1 {{Dereference of null pointer (loaded from variable 'a')}} +} + +void testStoreCheck(int *a) { + a = getPointer(); + // expected-note@-1 {{Value assigned to 'a'}} + check(a); + // expected-note@-1 {{Calling 'check'}} + // expected-note@-2 {{Returning from 'check'}} + *a = 1; // expected-warning{{Dereference of null pointer}} + // expected-note@-1 {{Dereference of null pointer (loaded from variable 'a')}} +} |