1//C
2void test() {
3 void (*foo)(void);
4 foo = 0;
5 foo(); // warn: function pointer is null
6 }
7
8 // C++
9 class C {
10 public:
11 void f();
12 };
13
14 void test() {
15 C *pc;
16 pc->f(); // warn: object pointer is uninitialized
17 }
18
19 // C++
20 class C {
21 public:
22 void f();
23 };
24
25 void test() {
26 C *pc = 0;
27 pc->f(); // warn: object pointer is null
28 }
29
30 // Objective-C
31 @interface MyClass : NSObject
32 @property (readwrite,assign) id x;
33 - (long double)longDoubleM;
34 @end
35
36 void test() {
37 MyClass *obj1;
38 long double ld1 = [obj1 longDoubleM];
39 // warn: receiver is uninitialized
40 }
41
42 // Objective-C
43 @interface MyClass : NSObject
44 @property (readwrite,assign) id x;
45 - (long double)longDoubleM;
46 @end
47
48 void test() {
49 MyClass *obj1;
50 id i = obj1.x; // warn: uninitialized object pointer
51 }
52
53 // Objective-C
54 @interface Subscriptable : NSObject
55 - (id)objectAtIndexedSubscript:(unsigned int)index;
56 @end
57
58 @interface MyClass : Subscriptable
59 @property (readwrite,assign) id x;
60 - (long double)longDoubleM;
61 @end
62
63 void test() {
64 MyClass *obj1;
65 id i = obj1[0]; // warn: uninitialized object pointer
66 }
67

source code of clang/docs/analyzer/checkers/callandmessage_example.c