[ELF] Reorder SectionBase/InputSectionBase members
[llvm-project.git] / clang / test / Analysis / plist-macros-with-expansion-ctu.c
blob956088cc0f675a732fdd0a23fa00396cae59b171
1 // RUN: rm -rf %t && mkdir %t
2 // RUN: mkdir -p %t/ctudir
3 // RUN: %clang_cc1 -emit-pch -o %t/ctudir/plist-macros-ctu.c.ast %S/Inputs/plist-macros-ctu.c
4 // RUN: cp %S/Inputs/plist-macros-with-expansion-ctu.c.externalDefMap.txt %t/ctudir/externalDefMap.txt
5 //
6 // RUN: %clang_analyze_cc1 -analyzer-checker=core \
7 // RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \
8 // RUN: -analyzer-config ctu-dir=%t/ctudir \
9 // RUN: -analyzer-config expand-macros=true \
10 // RUN: -analyzer-output=plist-multi-file -o %t.plist -verify %s
12 // Check the macro expansions from the plist output here, to make the test more
13 // understandable.
14 // RUN: FileCheck --input-file=%t.plist %s
16 extern void F1(int **);
17 extern void F2(int **);
18 extern void F3(int **);
19 extern void F_H(int **);
21 void test0(void) {
22 int *X;
23 F3(&X);
24 *X = 1; // expected-warning{{Dereference of null pointer}}
26 // FIXME: Macro expansion for other TUs should also work.
27 // CHECK: <key>macro_expansions</key>
28 // CHECK-NEXT: <array>
29 // CHECK-NEXT: </array>
31 void test1(void) {
32 int *X;
33 F1(&X);
34 *X = 1; // expected-warning{{Dereference of null pointer}}
37 // CHECK: <key>macro_expansions</key>
38 // CHECK-NEXT: <array>
39 // CHECK-NEXT: </array>
41 void test2(void) {
42 int *X;
43 F2(&X);
44 *X = 1; // expected-warning{{Dereference of null pointer}}
47 // CHECK: <key>macro_expansions</key>
48 // CHECK-NEXT: <array>
49 // CHECK-NEXT: </array>
51 #define M F1(&X)
53 void test3(void) {
54 int *X;
56 *X = 1; // expected-warning{{Dereference of null pointer}}
58 // Macro expansions for the main TU still works, even in CTU mode.
59 // CHECK: <key>macro_expansions</key>
60 // CHECK-NEXT: <array>
61 // CHECK-NEXT: <dict>
62 // CHECK-NEXT: <key>location</key>
63 // CHECK-NEXT: <dict>
64 // CHECK-NEXT: <key>line</key><integer>55</integer>
65 // CHECK-NEXT: <key>col</key><integer>3</integer>
66 // CHECK-NEXT: <key>file</key><integer>0</integer>
67 // CHECK-NEXT: </dict>
68 // CHECK-NEXT: <key>name</key><string>M</string>
69 // CHECK-NEXT: <key>expansion</key><string>F1 (&amp;X )</string>
70 // CHECK-NEXT: </dict>
71 // CHECK-NEXT: </array>
73 #undef M
74 #define M F2(&X)
76 void test4(void) {
77 int *X;
79 *X = 1; // expected-warning{{Dereference of null pointer}}
82 // CHECK: <key>macro_expansions</key>
83 // CHECK-NEXT: <array>
84 // CHECK-NEXT: <dict>
85 // CHECK-NEXT: <key>location</key>
86 // CHECK-NEXT: <dict>
87 // CHECK-NEXT: <key>line</key><integer>78</integer>
88 // CHECK-NEXT: <key>col</key><integer>3</integer>
89 // CHECK-NEXT: <key>file</key><integer>0</integer>
90 // CHECK-NEXT: </dict>
91 // CHECK-NEXT: <key>name</key><string>M</string>
92 // CHECK-NEXT: <key>expansion</key><string>F2 (&amp;X )</string>
93 // CHECK-NEXT: </dict>
94 // CHECK-NEXT: </array>
96 void test_h(void) {
97 int *X;
98 F_H(&X);
99 *X = 1; // expected-warning{{Dereference of null pointer}}
102 // CHECK: <key>macro_expansions</key>
103 // CHECK-NEXT: <array>
104 // CHECK-NEXT: </array>