1 // The slash direction in linux and windows are different.
2 // UNSUPPORTED: system-windows
6 // RUN: split-file %s %t
8 // RUN: sed "s|DIR|%/t|g" %t/P1689.json.in > %t/P1689.json
9 // RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | FileCheck %t/Checks.cpp -DPREFIX=%/t
10 // RUN: clang-scan-deps --mode=preprocess-dependency-directives -compilation-database %t/P1689.json -format=p1689 | FileCheck %t/Checks.cpp -DPREFIX=%/t
12 // Check the separated dependency format. This is required by CMake for the case
13 // that we have non-exist files in a fresh build and potentially out-of-date after that.
14 // So the build system need to wrtie a compilation database just for scanning purposes,
15 // which is not so good. So here is the per file mode for P1689.
16 // RUN: clang-scan-deps -format=p1689 \
17 // RUN: -- %clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/M.cppm -o %t/M.o \
18 // RUN: | FileCheck %t/M.cppm -DPREFIX=%/t
19 // RUN: clang-scan-deps -format=p1689 \
20 // RUN: -- %clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/Impl.cpp -o %t/Impl.o \
21 // RUN: | FileCheck %t/Impl.cpp -DPREFIX=%/t
22 // RUN: clang-scan-deps -format=p1689 \
23 // RUN: -- %clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/impl_part.cppm -o %t/impl_part.o \
24 // RUN: | FileCheck %t/impl_part.cppm -DPREFIX=%/t
25 // RUN: clang-scan-deps -format=p1689 \
26 // RUN: -- %clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/interface_part.cppm -o %t/interface_part.o \
27 // RUN: | FileCheck %t/interface_part.cppm -DPREFIX=%/t
28 // RUN: clang-scan-deps -format=p1689 \
29 // RUN: -- %clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/User.cpp -o %t/User.o \
30 // RUN: | FileCheck %t/User.cpp -DPREFIX=%/t
32 // Check we can generate the make-style dependencies as expected.
33 // RUN: clang-scan-deps -format=p1689 \
34 // RUN: -- %clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/impl_part.cppm -o %t/impl_part.o \
35 // RUN: -MT %t/impl_part.o.ddi -MD -MF %t/impl_part.dep
36 // RUN: cat %t/impl_part.dep | FileCheck %t/impl_part.cppm -DPREFIX=%/t --check-prefix=CHECK-MAKE
38 // Check that we can generate multiple make-style dependency information with compilation database.
39 // RUN: cat %t/P1689.dep | FileCheck %t/Checks.cpp -DPREFIX=%/t --check-prefix=CHECK-MAKE
45 "command": "clang++ -std=c++20 DIR/M.cppm -c -o DIR/M.o -MT DIR/M.o.ddi -MD -MF DIR/P1689.dep",
51 "command": "clang++ -std=c++20 DIR/Impl.cpp -c -o DIR/Impl.o -MT DIR/Impl.o.ddi -MD -MF DIR/P1689.dep",
52 "file": "DIR/Impl.cpp",
53 "output": "DIR/Impl.o"
57 "command": "clang++ -std=c++20 DIR/impl_part.cppm -c -o DIR/impl_part.o -MT DIR/impl_part.o.ddi -MD -MF DIR/P1689.dep",
58 "file": "DIR/impl_part.cppm",
59 "output": "DIR/impl_part.o"
63 "command": "clang++ -std=c++20 DIR/interface_part.cppm -c -o DIR/interface_part.o -MT DIR/interface_part.o.ddi -MD -MF DIR/P1689.dep",
64 "file": "DIR/interface_part.cppm",
65 "output": "DIR/interface_part.o"
69 "command": "clang++ -std=c++20 DIR/User.cpp -c -o DIR/User.o -MT DIR/User.o.ddi -MD -MF DIR/P1689.dep",
70 "file": "DIR/User.cpp",
71 "output": "DIR/User.o"
77 export import :interface_part;
82 // CHECK-NEXT: "revision": 0,
83 // CHECK-NEXT: "rules": [
85 // CHECK-NEXT: "primary-output": "[[PREFIX]]/M.o",
86 // CHECK-NEXT: "provides": [
88 // CHECK-NEXT: "is-interface": true,
89 // CHECK-NEXT: "logical-name": "M",
90 // CHECK-NEXT: "source-path": "[[PREFIX]]/M.cppm"
93 // CHECK-NEXT: "requires": [
95 // CHECK-NEXT: "logical-name": "M:interface_part"
98 // CHECK-NEXT: "logical-name": "M:impl_part"
103 // CHECK-NEXT: "version": 1
108 #include "header.mock"
111 std::cout << "Hello ";
115 // CHECK-NEXT: "revision": 0,
116 // CHECK-NEXT: "rules": [
118 // CHECK-NEXT: "primary-output": "[[PREFIX]]/Impl.o",
119 // CHECK-NEXT: "requires": [
121 // CHECK-NEXT: "logical-name": "M"
126 // CHECK-NEXT: "version": 1
131 #include "header.mock"
133 import :interface_part;
135 std::string W = "World.";
137 std::cout << W << std::endl;
141 // CHECK-NEXT: "revision": 0,
142 // CHECK-NEXT: "rules": [
144 // CHECK-NEXT: "primary-output": "[[PREFIX]]/impl_part.o",
145 // CHECK-NEXT: "provides": [
147 // CHECK-NEXT: "is-interface": false,
148 // CHECK-NEXT: "logical-name": "M:impl_part",
149 // CHECK-NEXT: "source-path": "[[PREFIX]]/impl_part.cppm"
152 // CHECK-NEXT: "requires": [
154 // CHECK-NEXT: "logical-name": "M:interface_part"
159 // CHECK-NEXT: "version": 1
162 // CHECK-MAKE: [[PREFIX]]/impl_part.o.ddi:
163 // CHECK-MAKE: [[PREFIX]]/impl_part.cppm
164 // CHECK-MAKE: [[PREFIX]]/header.mock
166 //--- interface_part.cppm
167 export module M:interface_part;
171 // CHECK-NEXT: "revision": 0,
172 // CHECK-NEXT: "rules": [
174 // CHECK-NEXT: "primary-output": "[[PREFIX]]/interface_part.o",
175 // CHECK-NEXT: "provides": [
177 // CHECK-NEXT: "is-interface": true,
178 // CHECK-NEXT: "logical-name": "M:interface_part",
179 // CHECK-NEXT: "source-path": "[[PREFIX]]/interface_part.cppm"
184 // CHECK-NEXT: "version": 1
189 import third_party_module;
197 // CHECK-NEXT: "revision": 0,
198 // CHECK-NEXT: "rules": [
200 // CHECK-NEXT: "primary-output": "[[PREFIX]]/User.o",
201 // CHECK-NEXT: "requires": [
203 // CHECK-NEXT: "logical-name": "M"
206 // CHECK-NEXT: "logical-name": "third_party_module"
211 // CHECK-NEXT: "version": 1
216 // CHECK-NEXT: "revision": 0,
217 // CHECK-NEXT: "rules": [
219 // CHECK-NEXT: "primary-output": "[[PREFIX]]/Impl.o",
220 // CHECK-NEXT: "requires": [
222 // CHECK-NEXT: "logical-name": "M",
223 // CHECK-NEXT: "source-path": "[[PREFIX]]/M.cppm"
228 // CHECK-NEXT: "primary-output": "[[PREFIX]]/M.o",
229 // CHECK-NEXT: "provides": [
231 // CHECK-NEXT: "is-interface": true,
232 // CHECK-NEXT: "logical-name": "M",
233 // CHECK-NEXT: "source-path": "[[PREFIX]]/M.cppm"
236 // CHECK-NEXT: "requires": [
238 // CHECK-NEXT: "logical-name": "M:interface_part",
239 // CHECK-NEXT: "source-path": "[[PREFIX]]/interface_part.cppm"
242 // CHECK-NEXT: "logical-name": "M:impl_part",
243 // CHECK-NEXT: "source-path": "[[PREFIX]]/impl_part.cppm"
248 // CHECK-NEXT: "primary-output": "[[PREFIX]]/User.o",
249 // CHECK-NEXT: "requires": [
251 // CHECK-NEXT: "logical-name": "M",
252 // CHECK-NEXT: "source-path": "[[PREFIX]]/M.cppm"
255 // CHECK-NEXT: "logical-name": "third_party_module"
260 // CHECK-NEXT: "primary-output": "[[PREFIX]]/impl_part.o",
261 // CHECK-NEXT: "provides": [
263 // CHECK-NEXT: "is-interface": false,
264 // CHECK-NEXT: "logical-name": "M:impl_part",
265 // CHECK-NEXT: "source-path": "[[PREFIX]]/impl_part.cppm"
268 // CHECK-NEXT: "requires": [
270 // CHECK-NEXT: "logical-name": "M:interface_part",
271 // CHECK-NEXT: "source-path": "[[PREFIX]]/interface_part.cppm"
276 // CHECK-NEXT: "primary-output": "[[PREFIX]]/interface_part.o",
277 // CHECK-NEXT: "provides": [
279 // CHECK-NEXT: "is-interface": true,
280 // CHECK-NEXT: "logical-name": "M:interface_part",
281 // CHECK-NEXT: "source-path": "[[PREFIX]]/interface_part.cppm"
286 // CHECK-NEXT: "version": 1
289 // CHECK-MAKE-DAG: [[PREFIX]]/impl_part.o.ddi: \
290 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/impl_part.cppm \
291 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/header.mock
292 // CHECK-MAKE-DAG: [[PREFIX]]/interface_part.o.ddi: \
293 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/interface_part.cppm
294 // CHECK-MAKE-DAG: [[PREFIX]]/M.o.ddi: \
295 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/M.cppm
296 // CHECK-MAKE-DAG: [[PREFIX]]/User.o.ddi: \
297 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/User.cpp
298 // CHECK-MAKE-DAG: [[PREFIX]]/Impl.o.ddi: \
299 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/Impl.cpp \
300 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/header.mock