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 5 6#include "Inputs/system-header-simulator-objc.h" 7 8void clang_analyzer_explain(void *); 9 10@interface Object : NSObject { 11@public 12 Object *x; 13} 14@end 15 16void 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\]'$}}}} 22} 23 24void test_2() { 25 __block int x; 26 ^{ 27 clang_analyzer_explain(&x); // expected-warning-re{{{{^pointer to block variable 'x'$}}}} 28 }; 29 clang_analyzer_explain(&x); // expected-warning-re{{{{^pointer to block variable 'x'$}}}} 30} 31 32@interface O 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; 37@end 38 39@implementation O 40+ (instancetype)top_level_class_method:(int)param { 41 clang_analyzer_explain(¶m); // expected-warning-re{{{{^pointer to parameter 'param'$}}}} 42} 43 44+ (instancetype)non_top_level_class_method:(int)param { 45 clang_analyzer_explain(¶m); // expected-warning-re{{{{^pointer to parameter 'param'$}}}} 46} 47 48- top_level_instance_method:(int)param { 49 clang_analyzer_explain(¶m); // expected-warning-re{{{{^pointer to parameter 'param'$}}}} 50} 51 52- non_top_level_instance_method:(int)param { 53 clang_analyzer_explain(¶m); // expected-warning-re{{{{^pointer to parameter 'param'$}}}} 54} 55@end 56 57void test_3(int n, int m) { 58 O *o = [O non_top_level_class_method:n]; 59 [o non_top_level_instance_method:m]; 60 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'$}}}} 64 }; 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'$}}}} 68 }; 69 70 block_non_top_level(n); 71} 72