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
41 // Check that we can mix the use of -format=p1689 and -fmodules.
42 // RUN: clang-scan-deps -format=p1689 \
43 // RUN: -- %clang++ -std=c++20 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -c %t/impl_part.cppm -o %t/impl_part.o \
44 // RUN: | FileCheck %t/impl_part.cppm -DPREFIX=%/t
46 // Check the path in the make style dependencies are generated in relative path form
48 // RUN: clang-scan-deps -format=p1689 \
49 // RUN: -- %clang++ -std=c++20 -c -fprebuilt-module-path=%t impl_part.cppm -o impl_part.o \
50 // RUN: -MT impl_part.o.ddi -MD -MF impl_part.dep
51 // RUN: cat impl_part.dep | FileCheck impl_part.cppm -DPREFIX=%/t --check-prefix=CHECK-MAKE-RELATIVE
58 "command": "clang++ -std=c++20 DIR/M.cppm -c -o DIR/M.o -MT DIR/M.o.ddi -MD -MF DIR/P1689.dep",
64 "command": "clang++ -std=c++20 DIR/Impl.cpp -c -o DIR/Impl.o -MT DIR/Impl.o.ddi -MD -MF DIR/P1689.dep",
65 "file": "DIR/Impl.cpp",
66 "output": "DIR/Impl.o"
70 "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",
71 "file": "DIR/impl_part.cppm",
72 "output": "DIR/impl_part.o"
76 "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",
77 "file": "DIR/interface_part.cppm",
78 "output": "DIR/interface_part.o"
82 "command": "clang++ -std=c++20 DIR/User.cpp -c -o DIR/User.o -MT DIR/User.o.ddi -MD -MF DIR/P1689.dep",
83 "file": "DIR/User.cpp",
84 "output": "DIR/User.o"
90 export import :interface_part;
95 // CHECK-NEXT: "revision": 0,
96 // CHECK-NEXT: "rules": [
98 // CHECK-NEXT: "primary-output": "[[PREFIX]]/M.o",
99 // CHECK-NEXT: "provides": [
101 // CHECK-NEXT: "is-interface": true,
102 // CHECK-NEXT: "logical-name": "M",
103 // CHECK-NEXT: "source-path": "[[PREFIX]]/M.cppm"
106 // CHECK-NEXT: "requires": [
108 // CHECK-NEXT: "logical-name": "M:interface_part"
111 // CHECK-NEXT: "logical-name": "M:impl_part"
116 // CHECK-NEXT: "version": 1
121 #include "header.mock"
124 std::cout << "Hello ";
128 // CHECK-NEXT: "revision": 0,
129 // CHECK-NEXT: "rules": [
131 // CHECK-NEXT: "primary-output": "[[PREFIX]]/Impl.o",
132 // CHECK-NEXT: "requires": [
134 // CHECK-NEXT: "logical-name": "M"
139 // CHECK-NEXT: "version": 1
144 #include "header.mock"
146 import :interface_part;
148 std::string W = "World.";
150 std::cout << W << std::endl;
154 // CHECK-NEXT: "revision": 0,
155 // CHECK-NEXT: "rules": [
157 // CHECK-NEXT: "primary-output": "[[PREFIX]]/impl_part.o",
158 // CHECK-NEXT: "provides": [
160 // CHECK-NEXT: "is-interface": false,
161 // CHECK-NEXT: "logical-name": "M:impl_part",
162 // CHECK-NEXT: "source-path": "[[PREFIX]]/impl_part.cppm"
165 // CHECK-NEXT: "requires": [
167 // CHECK-NEXT: "logical-name": "M:interface_part"
172 // CHECK-NEXT: "version": 1
175 // CHECK-MAKE: [[PREFIX]]/impl_part.o.ddi:
176 // CHECK-MAKE: [[PREFIX]]/impl_part.cppm
177 // CHECK-MAKE: [[PREFIX]]/header.mock
179 // CHECK-MAKE-RELATIVE: impl_part.o.ddi: impl_part.cppm header.mock
181 //--- interface_part.cppm
182 export module M:interface_part;
186 // CHECK-NEXT: "revision": 0,
187 // CHECK-NEXT: "rules": [
189 // CHECK-NEXT: "primary-output": "[[PREFIX]]/interface_part.o",
190 // CHECK-NEXT: "provides": [
192 // CHECK-NEXT: "is-interface": true,
193 // CHECK-NEXT: "logical-name": "M:interface_part",
194 // CHECK-NEXT: "source-path": "[[PREFIX]]/interface_part.cppm"
199 // CHECK-NEXT: "version": 1
204 import third_party_module;
212 // CHECK-NEXT: "revision": 0,
213 // CHECK-NEXT: "rules": [
215 // CHECK-NEXT: "primary-output": "[[PREFIX]]/User.o",
216 // CHECK-NEXT: "requires": [
218 // CHECK-NEXT: "logical-name": "M"
221 // CHECK-NEXT: "logical-name": "third_party_module"
226 // CHECK-NEXT: "version": 1
231 // CHECK-NEXT: "revision": 0,
232 // CHECK-NEXT: "rules": [
234 // CHECK-NEXT: "primary-output": "[[PREFIX]]/Impl.o",
235 // CHECK-NEXT: "requires": [
237 // CHECK-NEXT: "logical-name": "M",
238 // CHECK-NEXT: "source-path": "[[PREFIX]]/M.cppm"
243 // CHECK-NEXT: "primary-output": "[[PREFIX]]/M.o",
244 // CHECK-NEXT: "provides": [
246 // CHECK-NEXT: "is-interface": true,
247 // CHECK-NEXT: "logical-name": "M",
248 // CHECK-NEXT: "source-path": "[[PREFIX]]/M.cppm"
251 // CHECK-NEXT: "requires": [
253 // CHECK-NEXT: "logical-name": "M:interface_part",
254 // CHECK-NEXT: "source-path": "[[PREFIX]]/interface_part.cppm"
257 // CHECK-NEXT: "logical-name": "M:impl_part",
258 // CHECK-NEXT: "source-path": "[[PREFIX]]/impl_part.cppm"
263 // CHECK-NEXT: "primary-output": "[[PREFIX]]/User.o",
264 // CHECK-NEXT: "requires": [
266 // CHECK-NEXT: "logical-name": "M",
267 // CHECK-NEXT: "source-path": "[[PREFIX]]/M.cppm"
270 // CHECK-NEXT: "logical-name": "third_party_module"
275 // CHECK-NEXT: "primary-output": "[[PREFIX]]/impl_part.o",
276 // CHECK-NEXT: "provides": [
278 // CHECK-NEXT: "is-interface": false,
279 // CHECK-NEXT: "logical-name": "M:impl_part",
280 // CHECK-NEXT: "source-path": "[[PREFIX]]/impl_part.cppm"
283 // CHECK-NEXT: "requires": [
285 // CHECK-NEXT: "logical-name": "M:interface_part",
286 // CHECK-NEXT: "source-path": "[[PREFIX]]/interface_part.cppm"
291 // CHECK-NEXT: "primary-output": "[[PREFIX]]/interface_part.o",
292 // CHECK-NEXT: "provides": [
294 // CHECK-NEXT: "is-interface": true,
295 // CHECK-NEXT: "logical-name": "M:interface_part",
296 // CHECK-NEXT: "source-path": "[[PREFIX]]/interface_part.cppm"
301 // CHECK-NEXT: "version": 1
304 // CHECK-MAKE-DAG: [[PREFIX]]/impl_part.o.ddi: \
305 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/impl_part.cppm \
306 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/header.mock
307 // CHECK-MAKE-DAG: [[PREFIX]]/interface_part.o.ddi: \
308 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/interface_part.cppm
309 // CHECK-MAKE-DAG: [[PREFIX]]/M.o.ddi: \
310 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/M.cppm
311 // CHECK-MAKE-DAG: [[PREFIX]]/User.o.ddi: \
312 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/User.cpp
313 // CHECK-MAKE-DAG: [[PREFIX]]/Impl.o.ddi: \
314 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/Impl.cpp \
315 // CHECK-MAKE-DAG-NEXT: [[PREFIX]]/header.mock
317 //--- module.modulemap
318 module Mock { header "header.mock" }