diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Analysis/inlining/path-notes.c | 44 | ||||
-rw-r--r-- | test/Analysis/method-call-path-notes.cpp | 2 |
2 files changed, 44 insertions, 2 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')}} +} diff --git a/test/Analysis/method-call-path-notes.cpp b/test/Analysis/method-call-path-notes.cpp index 1e17b838cc..6298ca043f 100644 --- a/test/Analysis/method-call-path-notes.cpp +++ b/test/Analysis/method-call-path-notes.cpp @@ -24,7 +24,7 @@ void test_ic_set_to_null() { } void test_ic_null(TestInstanceCall *p) { - if (!p) // expected-note {{Taking true branch}} + if (!p) // expected-note {{Assuming pointer value is null}} expected-note {{Taking true branch}} p->foo(); // expected-warning {{Called C++ object pointer is null}} expected-note{{Called C++ object pointer is null}} } |