1 // RUN: %clang_analyze_cc1 -w -triple i386-apple-darwin10 -fblocks -verify %s \
2 // RUN: -analyzer-checker=core.builtin \
3 // RUN: -analyzer-checker=debug.ExprInspection \
4 // RUN: -analyzer-config display-checker-name=false
6 #include "Inputs/system-header-simulator-objc.h"
8 void clang_analyzer_explain(void *);
10 @interface Object : NSObject {
16 void test_1(Object *p) {
17 clang_analyzer_explain(p); // expected-warning-re{{{{^argument 'p'$}}}}
18 clang_analyzer_explain(p->x); // expected-warning-re{{{{^initial value of instance variable 'x' of object at argument 'p'$}}}}
19 Object *q = [[Object alloc] init];
20 clang_analyzer_explain(q); // expected-warning-re{{{{^symbol of type 'Object \*' conjured at statement '\[\[Object alloc\] init\]'$}}}}
21 clang_analyzer_explain(q->x); // expected-warning-re{{{{^initial value of instance variable 'x' of object at symbol of type 'Object \*' conjured at statement '\[\[Object alloc\] init\]'$}}}}
27 clang_analyzer_explain(&x); // expected-warning-re{{{{^pointer to block variable 'x'$}}}}
29 clang_analyzer_explain(&x); // expected-warning-re{{{{^pointer to block variable 'x'$}}}}
33 + (instancetype)top_level_class_method:(int)param;
34 + (instancetype)non_top_level_class_method:(int)param;
35 - top_level_instance_method:(int)param;
36 - non_top_level_instance_method:(int)param;
40 + (instancetype)top_level_class_method:(int)param {
41 clang_analyzer_explain(¶m); // expected-warning-re{{{{^pointer to parameter 'param'$}}}}
44 + (instancetype)non_top_level_class_method:(int)param {
45 clang_analyzer_explain(¶m); // expected-warning-re{{{{^pointer to parameter 'param'$}}}}
48 - top_level_instance_method:(int)param {
49 clang_analyzer_explain(¶m); // expected-warning-re{{{{^pointer to parameter 'param'$}}}}
52 - non_top_level_instance_method:(int)param {
53 clang_analyzer_explain(¶m); // expected-warning-re{{{{^pointer to parameter 'param'$}}}}
57 void test_3(int n, int m) {
58 O *o = [O non_top_level_class_method:n];
59 [o non_top_level_instance_method:m];
61 void (^block_top_level)(int) = ^(int param) {
62 clang_analyzer_explain(¶m); // expected-warning-re{{{{^pointer to parameter 'param'$}}}}
63 clang_analyzer_explain(&n); // expected-warning-re{{{{^pointer to parameter 'n'$}}}}
65 void (^block_non_top_level)(int) = ^(int param) {
66 clang_analyzer_explain(¶m); // expected-warning-re{{{{^pointer to parameter 'param'$}}}}
67 clang_analyzer_explain(&n); // expected-warning-re{{{{^pointer to parameter 'n'$}}}}
70 block_non_top_level(n);