xref: /aosp_15_r20/external/clang/test/Driver/cl-pch-showincludes.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // Note: %s and %S must be preceded by --, otherwise it may be interpreted as a
2*67e74705SXin Li // command-line option, e.g. on Mac where %s is commonly under /Users.
3*67e74705SXin Li 
4*67e74705SXin Li // Tests interaction of /Yc / /Yu with /showIncludes
5*67e74705SXin Li // REQUIRES: x86-registered-target
6*67e74705SXin Li 
7*67e74705SXin Li #include "header3.h"
8*67e74705SXin Li 
9*67e74705SXin Li // When building the pch, header1.h (included by header2.h), header2.h (the pch
10*67e74705SXin Li // input itself) and header3.h (included directly, above) should be printed.
11*67e74705SXin Li // RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
12*67e74705SXin Li // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YC %s
13*67e74705SXin Li // CHECK-YC: Note: including file: {{[^ ]*header2.h}}
14*67e74705SXin Li // CHECK-YC: Note: including file:  {{[^ ]*header1.h}}
15*67e74705SXin Li // CHECK-YC: Note: including file: {{[^ ]*header3.h}}
16*67e74705SXin Li 
17*67e74705SXin Li // When using the pch, only the direct include is printed.
18*67e74705SXin Li // RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
19*67e74705SXin Li // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YU %s
20*67e74705SXin Li // CHECK-YU-NOT: Note: including file: {{.*pch}}
21*67e74705SXin Li // CHECK-YU-NOT: Note: including file: {{.*header1.h}}
22*67e74705SXin Li // CHECK-YU-NOT: Note: including file: {{.*header2.h}}
23*67e74705SXin Li // CHECK-YU: Note: including file: {{[^ ]*header3.h}}
24*67e74705SXin Li 
25*67e74705SXin Li // When not using pch at all, all the /FI files are printed.
26*67e74705SXin Li // RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /FIheader2.h /c /Fo%t -- %s \
27*67e74705SXin Li // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-FI %s
28*67e74705SXin Li // CHECK-FI: Note: including file: {{[^ ]*header2.h}}
29*67e74705SXin Li // CHECK-FI: Note: including file:  {{[^ ]*header1.h}}
30*67e74705SXin Li // CHECK-FI: Note: including file: {{[^ ]*header3.h}}
31*67e74705SXin Li 
32*67e74705SXin Li // Also check that /FI arguments before the /Yc / /Yu flags are printed right.
33*67e74705SXin Li 
34*67e74705SXin Li // /FI flags before the /Yc arg should be printed, /FI flags after it shouldn't.
35*67e74705SXin Li // RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader0.h /FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
36*67e74705SXin Li // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YCFI %s
37*67e74705SXin Li // CHECK-YCFI: Note: including file: {{[^ ]*header0.h}}
38*67e74705SXin Li // CHECK-YCFI: Note: including file: {{[^ ]*header2.h}}
39*67e74705SXin Li // CHECK-YCFI: Note: including file:  {{[^ ]*header1.h}}
40*67e74705SXin Li // CHECK-YCFI: Note: including file: {{[^ ]*header4.h}}
41*67e74705SXin Li // CHECK-YCFI: Note: including file: {{[^ ]*header3.h}}
42*67e74705SXin Li 
43*67e74705SXin Li // RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader0.h /FIheader2.h /FIheader4.h /Fp%t.pch /c /Fo%t -- %s \
44*67e74705SXin Li // RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YUFI %s
45*67e74705SXin Li // CHECK-YUFI-NOT: Note: including file: {{.*pch}}
46*67e74705SXin Li // CHECK-YUFI-NOT: Note: including file: {{.*header0.h}}
47*67e74705SXin Li // CHECK-YUFI-NOT: Note: including file: {{.*header2.h}}
48*67e74705SXin Li // CHECK-YUFI-NOT: Note: including file: {{.*header1.h}}
49*67e74705SXin Li // CHECK-YUFI: Note: including file: {{[^ ]*header4.h}}
50*67e74705SXin Li // CHECK-YUFI: Note: including file: {{[^ ]*header3.h}}
51