From 8d3ad6b6171531f258d26a250ccf26ecdea96430 Mon Sep 17 00:00:00 2001 From: Gabor Horvath Date: Thu, 27 Aug 2015 18:49:07 +0000 Subject: [Static Analyzer] Make NonNullParamChecker emit implicit null dereference events. Differential Revision: http://reviews.llvm.org/D11433 llvm-svn: 246182 --- clang/test/Analysis/nullability.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'clang/test') diff --git a/clang/test/Analysis/nullability.mm b/clang/test/Analysis/nullability.mm index 4b68e3da995..ec7ea3acada 100644 --- a/clang/test/Analysis/nullability.mm +++ b/clang/test/Analysis/nullability.mm @@ -50,6 +50,8 @@ int *_Nullable returnsNullableInt(); template T *eraseNullab(T *p) { return p; } +void takesAttrNonnull(Dummy *p) __attribute((nonnull(1))); + void testBasicRules() { Dummy *p = returnsNullable(); int *ptr = returnsNullableInt(); @@ -73,10 +75,8 @@ void testBasicRules() { Dummy dd(d); break; } - // Here the copy constructor is called, so a reference is initialized with the - // value of p. No ImplicitNullDereference event will be dispatched for this - // case. A followup patch is expected to fix this in NonNullParamChecker. - default: { Dummy d = *p; } break; // No warning. + case 5: takesAttrNonnull(p); break; // expected-warning {{Nullable pointer is passed to}} + default: { Dummy d = *p; } break; // expected-warning {{Nullable pointer is dereferenced}} } if (p) { takesNonnull(p); -- cgit v1.2.3