[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / ClangScanDeps / modules-pch.c
blob3e8471b810a5752059199ff93c2638013f8a818d
1 // Unsupported on AIX because we don't support the requisite "__clangast"
2 // section in XCOFF yet.
3 // UNSUPPORTED: target={{.*}}-aix{{.*}}
5 // RUN: rm -rf %t && mkdir %t
6 // RUN: cp %S/Inputs/modules-pch/* %t
8 // Scan dependencies of the PCH:
9 //
10 // RUN: rm -f %t/cdb_pch.json
11 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb_pch.json
12 // RUN: clang-scan-deps -compilation-database %t/cdb_pch.json -format experimental-full \
13 // RUN: -module-files-dir %t/build > %t/result_pch.json
14 // RUN: cat %t/result_pch.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-PCH
16 // Check we didn't build the PCH during dependency scanning.
17 // RUN: not cat %/t/pch.h.pch
19 // CHECK-PCH: {
20 // CHECK-PCH-NEXT: "modules": [
21 // CHECK-PCH-NEXT: {
22 // CHECK-PCH-NEXT: "clang-module-deps": [],
23 // CHECK-PCH-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
24 // CHECK-PCH-NEXT: "command-line": [
25 // CHECK-PCH: ],
26 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON_1:.*]]",
27 // CHECK-PCH-NEXT: "file-deps": [
28 // CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_1.h",
29 // CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
30 // CHECK-PCH-NEXT: ],
31 // CHECK-PCH-NEXT: "name": "ModCommon1"
32 // CHECK-PCH-NEXT: },
33 // CHECK-PCH-NEXT: {
34 // CHECK-PCH-NEXT: "clang-module-deps": [],
35 // CHECK-PCH-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
36 // CHECK-PCH-NEXT: "command-line": [
37 // CHECK-PCH: ],
38 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON_2:.*]]",
39 // CHECK-PCH-NEXT: "file-deps": [
40 // CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_2.h",
41 // CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
42 // CHECK-PCH-NEXT: ],
43 // CHECK-PCH-NEXT: "name": "ModCommon2"
44 // CHECK-PCH-NEXT: },
45 // CHECK-PCH-NEXT: {
46 // CHECK-PCH-NEXT: "clang-module-deps": [
47 // CHECK-PCH-NEXT: {
48 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON_2]]",
49 // CHECK-PCH-NEXT: "module-name": "ModCommon2"
50 // CHECK-PCH-NEXT: }
51 // CHECK-PCH-NEXT: ],
52 // CHECK-PCH-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
53 // CHECK-PCH-NEXT: "command-line": [
54 // CHECK-PCH: ],
55 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_PCH:.*]]",
56 // CHECK-PCH-NEXT: "file-deps": [
57 // CHECK-PCH-NEXT: "[[PREFIX]]/mod_pch.h",
58 // CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
59 // CHECK-PCH-NEXT: ],
60 // CHECK-PCH-NEXT: "name": "ModPCH"
61 // CHECK-PCH-NEXT: }
62 // CHECK-PCH-NEXT: ],
63 // CHECK-PCH-NEXT: "translation-units": [
64 // CHECK-PCH-NEXT: {
65 // CHECK-PCH: "clang-context-hash": "[[HASH_PCH:.*]]",
66 // CHECK-PCH-NEXT: "clang-module-deps": [
67 // CHECK-PCH-NEXT: {
68 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON_1]]",
69 // CHECK-PCH-NEXT: "module-name": "ModCommon1"
70 // CHECK-PCH-NEXT: },
71 // CHECK-PCH-NEXT: {
72 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_PCH]]",
73 // CHECK-PCH-NEXT: "module-name": "ModPCH"
74 // CHECK-PCH-NEXT: }
75 // CHECK-PCH-NEXT: ],
76 // CHECK-PCH-NEXT: "command-line": [
77 // CHECK-PCH: ],
78 // CHECK-PCH: "file-deps": [
79 // CHECK-PCH-NEXT: "[[PREFIX]]/pch.h"
80 // CHECK-PCH-NEXT: ],
81 // CHECK-PCH-NEXT: "input-file": "[[PREFIX]]/pch.h"
82 // CHECK-PCH-NEXT: }
84 // Explicitly build the PCH:
86 // RUN: %deps-to-rsp %t/result_pch.json --module-name=ModCommon1 > %t/mod_common_1.cc1.rsp
87 // RUN: %deps-to-rsp %t/result_pch.json --module-name=ModCommon2 > %t/mod_common_2.cc1.rsp
88 // RUN: %deps-to-rsp %t/result_pch.json --module-name=ModPCH > %t/mod_pch.cc1.rsp
89 // RUN: %deps-to-rsp %t/result_pch.json --tu-index=0 > %t/pch.rsp
91 // RUN: %clang @%t/mod_common_1.cc1.rsp
92 // RUN: %clang @%t/mod_common_2.cc1.rsp
93 // RUN: %clang @%t/mod_pch.cc1.rsp
94 // RUN: %clang @%t/pch.rsp
96 // Scan dependencies of the TU:
98 // RUN: rm -f %t/cdb_tu.json
99 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb_tu.json
100 // RUN: clang-scan-deps -compilation-database %t/cdb_tu.json -format experimental-full \
101 // RUN: -module-files-dir %t/build > %t/result_tu.json
102 // RUN: cat %t/result_tu.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-TU
104 // CHECK-TU: {
105 // CHECK-TU-NEXT: "modules": [
106 // CHECK-TU-NEXT: {
107 // CHECK-TU-NEXT: "clang-module-deps": [],
108 // CHECK-TU-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
109 // CHECK-TU-NEXT: "command-line": [
110 // CHECK-TU: ],
111 // CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU:.*]]",
112 // CHECK-TU-NEXT: "file-deps": [
113 // CHECK-TU-NEXT: "[[PREFIX]]/mod_tu.h",
114 // CHECK-TU-NEXT: "[[PREFIX]]/module.modulemap"
115 // CHECK-TU-NEXT: ],
116 // CHECK-TU-NEXT: "name": "ModTU"
117 // CHECK-TU-NEXT: }
118 // CHECK-TU-NEXT: ],
119 // CHECK-TU-NEXT: "translation-units": [
120 // CHECK-TU-NEXT: {
121 // CHECK-TU: "clang-context-hash": "[[HASH_TU:.*]]",
122 // CHECK-TU-NEXT: "clang-module-deps": [
123 // CHECK-TU-NEXT: {
124 // CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU]]",
125 // CHECK-TU-NEXT: "module-name": "ModTU"
126 // CHECK-TU-NEXT: }
127 // CHECK-TU-NEXT: ],
128 // CHECK-TU-NEXT: "command-line": [
129 // CHECK-TU: ],
130 // CHECK-TU: "file-deps": [
131 // CHECK-TU-NEXT: "[[PREFIX]]/tu.c",
132 // CHECK-TU-NEXT: "[[PREFIX]]/pch.h.pch"
133 // CHECK-TU-NEXT: ],
134 // CHECK-TU-NEXT: "input-file": "[[PREFIX]]/tu.c"
135 // CHECK-TU-NEXT: }
137 // Explicitly build the TU:
139 // RUN: %deps-to-rsp %t/result_tu.json --module-name=ModTU > %t/mod_tu.cc1.rsp
140 // RUN: %deps-to-rsp %t/result_tu.json --tu-index=0 > %t/tu.rsp
142 // RUN: %clang @%t/mod_tu.cc1.rsp
143 // RUN: %clang @%t/tu.rsp
145 // Scan dependencies of the TU that has common modules with the PCH:
147 // RUN: rm -f %t/cdb_tu_with_common.json
148 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu_with_common.json > %t/cdb_tu_with_common.json
149 // RUN: clang-scan-deps -compilation-database %t/cdb_tu_with_common.json -format experimental-full \
150 // RUN: -module-files-dir %t/build > %t/result_tu_with_common.json
151 // RUN: cat %t/result_tu_with_common.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-TU-WITH-COMMON
153 // CHECK-TU-WITH-COMMON: {
154 // CHECK-TU-WITH-COMMON-NEXT: "modules": [
155 // CHECK-TU-WITH-COMMON-NEXT: {
156 // CHECK-TU-WITH-COMMON-NEXT: "clang-module-deps": [],
157 // CHECK-TU-WITH-COMMON-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
158 // CHECK-TU-WITH-COMMON-NEXT: "command-line": [
159 // CHECK-TU-WITH-COMMON: ],
160 // CHECK-TU-WITH-COMMON-NEXT: "context-hash": "[[HASH_MOD_TU_WITH_COMMON:.*]]",
161 // CHECK-TU-WITH-COMMON-NEXT: "file-deps": [
162 // CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/mod_tu_with_common.h",
163 // CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/module.modulemap"
164 // CHECK-TU-WITH-COMMON-NEXT: ],
165 // CHECK-TU-WITH-COMMON-NEXT: "name": "ModTUWithCommon"
166 // CHECK-TU-WITH-COMMON-NEXT: }
167 // CHECK-TU-WITH-COMMON-NEXT: ],
168 // CHECK-TU-WITH-COMMON-NEXT: "translation-units": [
169 // CHECK-TU-WITH-COMMON-NEXT: {
170 // CHECK-TU-WITH-COMMON: "clang-context-hash": "[[HASH_TU_WITH_COMMON:.*]]",
171 // CHECK-TU-WITH-COMMON-NEXT: "clang-module-deps": [
172 // CHECK-TU-WITH-COMMON-NEXT: {
173 // CHECK-TU-WITH-COMMON-NEXT: "context-hash": "[[HASH_MOD_TU_WITH_COMMON]]",
174 // CHECK-TU-WITH-COMMON-NEXT: "module-name": "ModTUWithCommon"
175 // CHECK-TU-WITH-COMMON-NEXT: }
176 // CHECK-TU-WITH-COMMON-NEXT: ],
177 // CHECK-TU-WITH-COMMON-NEXT: "command-line": [
178 // CHECK-TU-WITH-COMMON: "-fmodule-file=[[PREFIX]]/build/{{.*}}/ModCommon2-{{.*}}.pcm"
179 // CHECK-TU-WITH-COMMON: ],
180 // CHECK-TU-WITH-COMMON: "file-deps": [
181 // CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/tu_with_common.c",
182 // CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/pch.h.pch"
183 // CHECK-TU-WITH-COMMON-NEXT: ],
184 // CHECK-TU-WITH-COMMON-NEXT: "input-file": "[[PREFIX]]/tu_with_common.c"
185 // CHECK-TU-WITH-COMMON-NEXT: }
187 // Explicitly build the TU that has common modules with the PCH:
189 // RUN: %deps-to-rsp %t/result_tu_with_common.json --module-name=ModTUWithCommon > %t/mod_tu_with_common.cc1.rsp
190 // RUN: %deps-to-rsp %t/result_tu_with_common.json --tu-index=0 > %t/tu_with_common.rsp
192 // RUN: %clang @%t/mod_tu_with_common.cc1.rsp
193 // RUN: %clang @%t/tu_with_common.rsp