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
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
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 **);
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>
34 *X
= 1; // expected-warning{{Dereference of null pointer}}
37 // CHECK: <key>macro_expansions</key>
38 // CHECK-NEXT: <array>
39 // CHECK-NEXT: </array>
44 *X
= 1; // expected-warning{{Dereference of null pointer}}
47 // CHECK: <key>macro_expansions</key>
48 // CHECK-NEXT: <array>
49 // CHECK-NEXT: </array>
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>
62 // CHECK-NEXT: <key>location</key>
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 (&X )</string>
70 // CHECK-NEXT: </dict>
71 // CHECK-NEXT: </array>
79 *X
= 1; // expected-warning{{Dereference of null pointer}}
82 // CHECK: <key>macro_expansions</key>
83 // CHECK-NEXT: <array>
85 // CHECK-NEXT: <key>location</key>
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 (&X )</string>
93 // CHECK-NEXT: </dict>
94 // CHECK-NEXT: </array>
99 *X
= 1; // expected-warning{{Dereference of null pointer}}
102 // CHECK: <key>macro_expansions</key>
103 // CHECK-NEXT: <array>
104 // CHECK-NEXT: </array>