1 // Check that a module from -fmodule-name= does not accidentally pick up extra
2 // dependencies that come from a PCH.
5 // RUN: split-file %s %t
6 // RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
7 // RUN: sed "s|DIR|%/t|g" %t/cdb_pch.json.template > %t/cdb_pch.json
10 // RUN: clang-scan-deps -compilation-database %t/cdb_pch.json \
11 // RUN: -format experimental-full -mode preprocess-dependency-directives \
12 // RUN: > %t/deps_pch.json
15 // RUN: %deps-to-rsp %t/deps_pch.json --module-name A > %t/A.rsp
16 // RUN: %deps-to-rsp %t/deps_pch.json --module-name B > %t/B.rsp
17 // RUN: %deps-to-rsp %t/deps_pch.json --tu-index 0 > %t/pch.rsp
18 // RUN: %clang @%t/A.rsp
19 // RUN: %clang @%t/B.rsp
20 // RUN: %clang @%t/pch.rsp
23 // RUN: clang-scan-deps -compilation-database %t/cdb.json \
24 // RUN: -format experimental-full -mode preprocess-dependency-directives \
25 // RUN: > %t/deps.json
27 // RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
29 // Verify that the only modular import in C is E and not the unrelated modules
30 // A or B that come from the PCH.
33 // CHECK-NEXT: "modules": [
35 // CHECK: "clang-module-deps": [
37 // CHECK: "module-name": "E"
40 // CHECK: "clang-modulemap-file": "[[PREFIX]]/module.modulemap"
41 // CHECK: "command-line": [
42 // CHECK-NOT: "-fmodule-file=
43 // CHECK: "-fmodule-file={{(E=)?}}[[PREFIX]]/{{.*}}/E-{{.*}}.pcm"
44 // CHECK-NOT: "-fmodule-file=
50 //--- cdb_pch.json.template
52 "file": "DIR/prefix.h",
54 "command": "clang -x c-header DIR/prefix.h -o DIR/prefix.h.pch -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache"
57 //--- cdb.json.template
61 "command": "clang -fsyntax-only DIR/tu.c -include DIR/prefix.h -fmodule-name=C -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache"
64 //--- module.modulemap
65 module A
{ header
"A.h" export
* }
66 module B
{ header
"B.h" export
* }
67 module C
{ header
"C.h" export
* }
68 module D
{ header
"D.h" export
* }
69 module E
{ header
"E.h" export
* }
78 struct B
{ struct A a
; };
83 struct C
{ struct E e
; };
88 struct D
{ struct C c
; };
98 // C.h is first included textually due to -fmodule-name=C.
100 // importing D pulls in a modular import of C; it's this build of C that we
101 // are verifying above