| 1 |
// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core \ |
| 2 |
// RUN: -analyzer-checker=nullability.NullPassedToNonnull \ |
| 3 |
// RUN: -analyzer-checker=nullability.NullReturnedFromNonnull \ |
| 4 |
// RUN: -analyzer-checker=nullability.NullablePassedToNonnull \ |
| 5 |
// RUN: -analyzer-checker=nullability.NullableReturnedFromNonnull \ |
| 6 |
// RUN: -analyzer-checker=nullability.NullableDereferenced \ |
| 7 |
// RUN: -analyzer-checker=debug.ExprInspection \ |
| 8 |
// RUN: -analyzer-output=text -verify %s |
| 9 |
// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core \ |
| 10 |
// RUN: -analyzer-checker=nullability.NullPassedToNonnull \ |
| 11 |
// RUN: -analyzer-checker=nullability.NullReturnedFromNonnull \ |
| 12 |
// RUN: -analyzer-checker=nullability.NullablePassedToNonnull \ |
| 13 |
// RUN: -analyzer-checker=nullability.NullableReturnedFromNonnull \ |
| 14 |
// RUN: -analyzer-checker=nullability.NullableDereferenced \ |
| 15 |
// RUN: -analyzer-output=plist -o %t.plist %s |
| 16 |
// RUN: %normalize_plist <%t.plist \ |
| 17 |
// RUN: | diff -ub %S/Inputs/expected-plists/nullability-notes.m.plist - |
| 18 |
|
| 19 |
void clang_analyzer_warnOnDeadSymbol(id); |
| 20 |
|
| 21 |
#include "Inputs/system-header-simulator-for-nullability.h" |
| 22 |
|
| 23 |
void takesNonnull(NSObject *_Nonnull y); |
| 24 |
|
| 25 |
@interface ClassWithProperties: NSObject |
| 26 |
@property(copy, nullable) NSObject *x; // plist check ensures no control flow piece from here to 'self.x'. |
| 27 |
-(void) method; |
| 28 |
@end; |
| 29 |
@implementation ClassWithProperties |
| 30 |
-(void) method { |
| 31 |
clang_analyzer_warnOnDeadSymbol(self); |
| 32 |
// no-crash |
| 33 |
NSObject *x = self.x; // expected-note{{Nullability 'nullable' is inferred}} |
| 34 |
// expected-warning@-1{{SYMBOL DEAD}} |
| 35 |
// expected-note@-2 {{SYMBOL DEAD}} |
| 36 |
takesNonnull(x); // expected-warning{{Nullable pointer is passed to a callee that requires a non-null 1st parameter}} |
| 37 |
// expected-note@-1{{Nullable pointer is passed to a callee that requires a non-null 1st parameter}} |
| 38 |
} |
| 39 |
@end |
| 40 |
|