[Clang] Delegate part of SetupConstraintScope's job to LambdaScopeForCallOperatorInst...
[llvm-project.git] / clang / test / ClangScanDeps / modules-pch.c
blob92b7f41ac4b9f99d5f7f380c09f977cf803e6b62
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]]/module.modulemap",
29 // CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_1.h"
30 // CHECK-PCH-NEXT: ],
31 // CHECK-PCH-NEXT: "link-libraries": [],
32 // CHECK-PCH-NEXT: "name": "ModCommon1"
33 // CHECK-PCH-NEXT: },
34 // CHECK-PCH-NEXT: {
35 // CHECK-PCH-NEXT: "clang-module-deps": [],
36 // CHECK-PCH-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
37 // CHECK-PCH-NEXT: "command-line": [
38 // CHECK-PCH: ],
39 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON_2:.*]]",
40 // CHECK-PCH-NEXT: "file-deps": [
41 // CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap",
42 // CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_2.h"
43 // CHECK-PCH-NEXT: ],
44 // CHECK-PCH-NEXT: "link-libraries": [],
45 // CHECK-PCH-NEXT: "name": "ModCommon2"
46 // CHECK-PCH-NEXT: },
47 // CHECK-PCH-NEXT: {
48 // CHECK-PCH-NEXT: "clang-module-deps": [
49 // CHECK-PCH-NEXT: {
50 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON_2]]",
51 // CHECK-PCH-NEXT: "module-name": "ModCommon2"
52 // CHECK-PCH-NEXT: }
53 // CHECK-PCH-NEXT: ],
54 // CHECK-PCH-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
55 // CHECK-PCH-NEXT: "command-line": [
56 // CHECK-PCH: ],
57 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_PCH:.*]]",
58 // CHECK-PCH-NEXT: "file-deps": [
59 // CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap",
60 // CHECK-PCH-NEXT: "[[PREFIX]]/mod_pch.h"
61 // CHECK-PCH-NEXT: ],
62 // CHECK-PCH-NEXT: "link-libraries": [],
63 // CHECK-PCH-NEXT: "name": "ModPCH"
64 // CHECK-PCH-NEXT: }
65 // CHECK-PCH-NEXT: ],
66 // CHECK-PCH-NEXT: "translation-units": [
67 // CHECK-PCH-NEXT: {
68 // CHECK-PCH: "clang-context-hash": "[[HASH_PCH:.*]]",
69 // CHECK-PCH-NEXT: "clang-module-deps": [
70 // CHECK-PCH-NEXT: {
71 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON_1]]",
72 // CHECK-PCH-NEXT: "module-name": "ModCommon1"
73 // CHECK-PCH-NEXT: },
74 // CHECK-PCH-NEXT: {
75 // CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_PCH]]",
76 // CHECK-PCH-NEXT: "module-name": "ModPCH"
77 // CHECK-PCH-NEXT: }
78 // CHECK-PCH-NEXT: ],
79 // CHECK-PCH-NEXT: "command-line": [
80 // CHECK-PCH: ],
81 // CHECK-PCH: "file-deps": [
82 // CHECK-PCH-NEXT: "[[PREFIX]]/pch.h"
83 // CHECK-PCH-NEXT: ],
84 // CHECK-PCH-NEXT: "input-file": "[[PREFIX]]/pch.h"
85 // CHECK-PCH-NEXT: }
87 // Explicitly build the PCH:
89 // RUN: %deps-to-rsp %t/result_pch.json --module-name=ModCommon1 > %t/mod_common_1.cc1.rsp
90 // RUN: %deps-to-rsp %t/result_pch.json --module-name=ModCommon2 > %t/mod_common_2.cc1.rsp
91 // RUN: %deps-to-rsp %t/result_pch.json --module-name=ModPCH > %t/mod_pch.cc1.rsp
92 // RUN: %deps-to-rsp %t/result_pch.json --tu-index=0 > %t/pch.rsp
94 // RUN: %clang @%t/mod_common_1.cc1.rsp
95 // RUN: %clang @%t/mod_common_2.cc1.rsp
96 // RUN: %clang @%t/mod_pch.cc1.rsp
97 // RUN: %clang @%t/pch.rsp
99 // Scan dependencies of the TU:
101 // RUN: rm -f %t/cdb_tu.json
102 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb_tu.json
103 // RUN: clang-scan-deps -compilation-database %t/cdb_tu.json -format experimental-full \
104 // RUN: -module-files-dir %t/build > %t/result_tu.json
105 // RUN: cat %t/result_tu.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-TU
107 // CHECK-TU: {
108 // CHECK-TU-NEXT: "modules": [
109 // CHECK-TU-NEXT: {
110 // CHECK-TU-NEXT: "clang-module-deps": [],
111 // CHECK-TU-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
112 // CHECK-TU-NEXT: "command-line": [
113 // CHECK-TU: ],
114 // CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU:.*]]",
115 // CHECK-TU-NEXT: "file-deps": [
116 // CHECK-TU-NEXT: "[[PREFIX]]/module.modulemap",
117 // CHECK-TU-NEXT: "[[PREFIX]]/mod_tu.h"
118 // CHECK-TU-NEXT: ],
119 // CHECK-TU-NEXT: "link-libraries": [],
120 // CHECK-TU-NEXT: "name": "ModTU"
121 // CHECK-TU-NEXT: }
122 // CHECK-TU-NEXT: ],
123 // CHECK-TU-NEXT: "translation-units": [
124 // CHECK-TU-NEXT: {
125 // CHECK-TU: "clang-context-hash": "[[HASH_TU:.*]]",
126 // CHECK-TU-NEXT: "clang-module-deps": [
127 // CHECK-TU-NEXT: {
128 // CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU]]",
129 // CHECK-TU-NEXT: "module-name": "ModTU"
130 // CHECK-TU-NEXT: }
131 // CHECK-TU-NEXT: ],
132 // CHECK-TU-NEXT: "command-line": [
133 // CHECK-TU: ],
134 // CHECK-TU: "file-deps": [
135 // CHECK-TU-NEXT: "[[PREFIX]]/tu.c",
136 // CHECK-TU-NEXT: "[[PREFIX]]/pch.h.pch"
137 // CHECK-TU-NEXT: ],
138 // CHECK-TU-NEXT: "input-file": "[[PREFIX]]/tu.c"
139 // CHECK-TU-NEXT: }
141 // Explicitly build the TU:
143 // RUN: %deps-to-rsp %t/result_tu.json --module-name=ModTU > %t/mod_tu.cc1.rsp
144 // RUN: %deps-to-rsp %t/result_tu.json --tu-index=0 > %t/tu.rsp
146 // RUN: %clang @%t/mod_tu.cc1.rsp
147 // RUN: %clang @%t/tu.rsp
149 // Scan dependencies of the TU that has common modules with the PCH:
151 // RUN: rm -f %t/cdb_tu_with_common.json
152 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu_with_common.json > %t/cdb_tu_with_common.json
153 // RUN: clang-scan-deps -compilation-database %t/cdb_tu_with_common.json -format experimental-full \
154 // RUN: -module-files-dir %t/build > %t/result_tu_with_common.json
155 // RUN: cat %t/result_tu_with_common.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-TU-WITH-COMMON
157 // CHECK-TU-WITH-COMMON: {
158 // CHECK-TU-WITH-COMMON-NEXT: "modules": [
159 // CHECK-TU-WITH-COMMON-NEXT: {
160 // CHECK-TU-WITH-COMMON-NEXT: "clang-module-deps": [],
161 // CHECK-TU-WITH-COMMON-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
162 // CHECK-TU-WITH-COMMON-NEXT: "command-line": [
163 // CHECK-TU-WITH-COMMON: ],
164 // CHECK-TU-WITH-COMMON-NEXT: "context-hash": "[[HASH_MOD_TU_WITH_COMMON:.*]]",
165 // CHECK-TU-WITH-COMMON-NEXT: "file-deps": [
166 // CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/module.modulemap",
167 // CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/mod_tu_with_common.h"
168 // CHECK-TU-WITH-COMMON-NEXT: ],
169 // CHECK-TU-WITH-COMMON-NEXT: "link-libraries": [],
170 // CHECK-TU-WITH-COMMON-NEXT: "name": "ModTUWithCommon"
171 // CHECK-TU-WITH-COMMON-NEXT: }
172 // CHECK-TU-WITH-COMMON-NEXT: ],
173 // CHECK-TU-WITH-COMMON-NEXT: "translation-units": [
174 // CHECK-TU-WITH-COMMON-NEXT: {
175 // CHECK-TU-WITH-COMMON: "clang-context-hash": "[[HASH_TU_WITH_COMMON:.*]]",
176 // CHECK-TU-WITH-COMMON-NEXT: "clang-module-deps": [
177 // CHECK-TU-WITH-COMMON-NEXT: {
178 // CHECK-TU-WITH-COMMON-NEXT: "context-hash": "[[HASH_MOD_TU_WITH_COMMON]]",
179 // CHECK-TU-WITH-COMMON-NEXT: "module-name": "ModTUWithCommon"
180 // CHECK-TU-WITH-COMMON-NEXT: }
181 // CHECK-TU-WITH-COMMON-NEXT: ],
182 // CHECK-TU-WITH-COMMON-NEXT: "command-line": [
183 // CHECK-TU-WITH-COMMON: "-fmodule-file=[[PREFIX]]/build/{{.*}}/ModCommon2-{{.*}}.pcm"
184 // CHECK-TU-WITH-COMMON: ],
185 // CHECK-TU-WITH-COMMON: "file-deps": [
186 // CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/tu_with_common.c",
187 // CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/pch.h.pch"
188 // CHECK-TU-WITH-COMMON-NEXT: ],
189 // CHECK-TU-WITH-COMMON-NEXT: "input-file": "[[PREFIX]]/tu_with_common.c"
190 // CHECK-TU-WITH-COMMON-NEXT: }
192 // Explicitly build the TU that has common modules with the PCH:
194 // RUN: %deps-to-rsp %t/result_tu_with_common.json --module-name=ModTUWithCommon > %t/mod_tu_with_common.cc1.rsp
195 // RUN: %deps-to-rsp %t/result_tu_with_common.json --tu-index=0 > %t/tu_with_common.rsp
197 // RUN: %clang @%t/mod_tu_with_common.cc1.rsp
198 // RUN: %clang @%t/tu_with_common.rsp