Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / docs / analyzer / checkers / callandmessage_example.c
blob7e14fbe464fcb8726c29c01207bb9fe0fb497dca
1 //C
2 void test() {
3 void (*foo)(void);
4 foo = 0;
5 foo(); // warn: function pointer is null
8 // C++
9 class C {
10 public:
11 void f();
14 void test() {
15 C *pc;
16 pc->f(); // warn: object pointer is uninitialized
19 // C++
20 class C {
21 public:
22 void f();
25 void test() {
26 C *pc = 0;
27 pc->f(); // warn: object pointer is null
30 // Objective-C
31 @interface MyClass : NSObject
32 @property (readwrite,assign) id x;
33 - (long double)longDoubleM;
34 @end
36 void test() {
37 MyClass *obj1;
38 long double ld1 = [obj1 longDoubleM];
39 // warn: receiver is uninitialized
42 // Objective-C
43 @interface MyClass : NSObject
44 @property (readwrite,assign) id x;
45 - (long double)longDoubleM;
46 @end
48 void test() {
49 MyClass *obj1;
50 id i = obj1.x; // warn: uninitialized object pointer
53 // Objective-C
54 @interface Subscriptable : NSObject
55 - (id)objectAtIndexedSubscript:(unsigned int)index;
56 @end
58 @interface MyClass : Subscriptable
59 @property (readwrite,assign) id x;
60 - (long double)longDoubleM;
61 @end
63 void test() {
64 MyClass *obj1;
65 id i = obj1[0]; // warn: uninitialized object pointer