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:
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
20 // CHECK-PCH-NEXT: "modules": [
22 // CHECK-PCH-NEXT: "clang-module-deps": [],
23 // CHECK-PCH-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
24 // CHECK-PCH-NEXT: "command-line": [
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"
31 // CHECK-PCH-NEXT: "name": "ModCommon1"
34 // CHECK-PCH-NEXT: "clang-module-deps": [],
35 // CHECK-PCH-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
36 // CHECK-PCH-NEXT: "command-line": [
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"
43 // CHECK-PCH-NEXT: "name": "ModCommon2"
46 // CHECK-PCH-NEXT: "clang-module-deps": [
48 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON_2]]",
49 // CHECK-PCH-NEXT: "module-name": "ModCommon2"
52 // CHECK-PCH-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
53 // CHECK-PCH-NEXT: "command-line": [
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"
60 // CHECK-PCH-NEXT: "name": "ModPCH"
63 // CHECK-PCH-NEXT: "translation-units": [
65 // CHECK-PCH: "clang-context-hash": "[[HASH_PCH:.*]]",
66 // CHECK-PCH-NEXT: "clang-module-deps": [
68 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON_1]]",
69 // CHECK-PCH-NEXT: "module-name": "ModCommon1"
72 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_PCH]]",
73 // CHECK-PCH-NEXT: "module-name": "ModPCH"
76 // CHECK-PCH-NEXT: "command-line": [
78 // CHECK-PCH: "file-deps": [
79 // CHECK-PCH-NEXT: "[[PREFIX]]/pch.h"
81 // CHECK-PCH-NEXT: "input-file": "[[PREFIX]]/pch.h"
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
105 // CHECK-TU-NEXT: "modules": [
107 // CHECK-TU-NEXT: "clang-module-deps": [],
108 // CHECK-TU-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
109 // CHECK-TU-NEXT: "command-line": [
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"
116 // CHECK-TU-NEXT: "name": "ModTU"
119 // CHECK-TU-NEXT: "translation-units": [
121 // CHECK-TU: "clang-context-hash": "[[HASH_TU:.*]]",
122 // CHECK-TU-NEXT: "clang-module-deps": [
124 // CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU]]",
125 // CHECK-TU-NEXT: "module-name": "ModTU"
128 // CHECK-TU-NEXT: "command-line": [
130 // CHECK-TU: "file-deps": [
131 // CHECK-TU-NEXT: "[[PREFIX]]/tu.c",
132 // CHECK-TU-NEXT: "[[PREFIX]]/pch.h.pch"
134 // CHECK-TU-NEXT: "input-file": "[[PREFIX]]/tu.c"
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