| 1 |
// RUN: %clang_analyze_cc1 %s -verify \ |
| 2 |
// RUN: -analyzer-checker=core \ |
| 3 |
// RUN: -analyzer-config core.CallAndMessage:FunctionPointer=false \ |
| 4 |
// RUN: -analyzer-config core.CallAndMessage:ParameterCount=false \ |
| 5 |
// RUN: -analyzer-config core.CallAndMessage:CXXThisMethodCall=false \ |
| 6 |
// RUN: -analyzer-config core.CallAndMessage:CXXDeallocationArg=false \ |
| 7 |
// RUN: -analyzer-config core.CallAndMessage:ArgInitializedness=false \ |
| 8 |
// RUN: -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=false \ |
| 9 |
// RUN: -analyzer-config core.CallAndMessage:NilReceiver=true \ |
| 10 |
// RUN: -analyzer-config core.CallAndMessage:UndefReceiver=false \ |
| 11 |
// RUN: -analyzer-output=plist -o %t.plist |
| 12 |
// RUN: cat %t.plist | FileCheck %s |
| 13 |
|
| 14 |
@interface Foo |
| 15 |
- (int &)ref; |
| 16 |
@end |
| 17 |
|
| 18 |
Foo *getFoo() { return 0; } |
| 19 |
|
| 20 |
void testNullPointerSuppression() { |
| 21 |
getFoo().ref = 1; |
| 22 |
} |
| 23 |
|
| 24 |
void testPositiveNullReference() { |
| 25 |
Foo *x = 0; |
| 26 |
x.ref = 1; // expected-warning {{The receiver of message 'ref' is nil, which results in forming a null reference [core.CallAndMessage]}} |
| 27 |
} |
| 28 |
|
| 29 |
// TODO: If this hash ever changes, turn core.CallAndMessage:NilReceiver from a |
| 30 |
// checker option into a checker, as described in the CallAndMessage comments! |
| 31 |
// CHECK: <key>issue_hash_content_of_line_in_context</key> |
| 32 |
// CHECK-SAME: <string>abe2e0574dd901094c511bae2f93f926</string> |