[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / ClangScanDeps / modules-extern-submodule.c
blob61cc722e84bc017182880078affa484e9938dc18
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
4 //--- tu.m
5 @import first;
7 //--- first/first/module.modulemap
8 module first { header "first.h" }
9 //--- first/first/first.h
10 #include <second/sub.h>
12 //--- second/second/module.modulemap
13 module second { extern module sub "sub.modulemap" }
14 //--- second/second/sub.modulemap
15 module second.sub { header "sub.h" }
16 //--- second/second/sub.h
17 @import third;
19 //--- third/module.modulemap
20 module third {}
22 //--- cdb.json.template
24 "file": "DIR/tu.c",
25 "directory": "DIR",
26 "command": "clang -I DIR/first -I DIR/second -I DIR/third -fmodules -fmodules-cache-path=DIR/cache -c DIR/tu.m -o DIR/tu.o"
29 // RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
30 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json
31 // RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
33 // CHECK: {
34 // CHECK-NEXT: "modules": [
35 // CHECK-NEXT: {
36 // CHECK-NEXT: "clang-module-deps": [
37 // CHECK-NEXT: {
38 // CHECK-NEXT: "context-hash": "{{.*}}",
39 // CHECK-NEXT: "module-name": "second"
40 // CHECK-NEXT: }
41 // CHECK-NEXT: ],
42 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/first/first/module.modulemap",
43 // CHECK-NEXT: "command-line": [
44 // CHECK-NEXT: "-cc1",
45 // CHECK: "-fmodule-map-file=[[PREFIX]]/second/second/module.modulemap"
46 // CHECK-NOT: "-fmodule-map-file=[[PREFIX]]/second/second/sub.modulemap"
47 // CHECK-NOT: "-fmodule-map-file=[[PREFIX]]/third/module.modulemap"
48 // CHECK: "-fmodule-file=second=[[PREFIX]]/cache/{{.*}}/second-{{.*}}.pcm"
49 // CHECK: ],
50 // CHECK-NEXT: "context-hash": "{{.*}}",
51 // CHECK-NEXT: "file-deps": [
52 // CHECK-NEXT: "[[PREFIX]]/first/first/first.h",
53 // CHECK-NEXT: "[[PREFIX]]/first/first/module.modulemap",
54 // CHECK-NEXT: "[[PREFIX]]/second/second/module.modulemap",
55 // CHECK-NEXT: "[[PREFIX]]/second/second/sub.modulemap"
56 // CHECK-NEXT: ],
57 // CHECK-NEXT: "name": "first"
58 // CHECK-NEXT: },
59 // CHECK-NEXT: {
60 // CHECK-NEXT: "clang-module-deps": [
61 // CHECK-NEXT: {
62 // CHECK-NEXT: "context-hash": "{{.*}}",
63 // CHECK-NEXT: "module-name": "third"
64 // CHECK-NEXT: }
65 // CHECK-NEXT: ],
66 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/second/second/module.modulemap",
67 // CHECK-NEXT: "command-line": [
68 // CHECK-NEXT: "-cc1",
69 // CHECK: "-fmodule-map-file=[[PREFIX]]/third/module.modulemap",
70 // CHECK: "-fmodule-file=third=[[PREFIX]]/cache/{{.*}}/third-{{.*}}.pcm",
71 // CHECK: ],
72 // CHECK-NEXT: "context-hash": "{{.*}}",
73 // CHECK-NEXT: "file-deps": [
74 // CHECK-NEXT: "[[PREFIX]]/second/second/module.modulemap",
75 // CHECK-NEXT: "[[PREFIX]]/second/second/sub.h",
76 // CHECK-NEXT: "[[PREFIX]]/second/second/sub.modulemap",
77 // CHECK-NEXT: "[[PREFIX]]/third/module.modulemap"
78 // CHECK-NEXT: ],
79 // CHECK-NEXT: "name": "second"
80 // CHECK-NEXT: },
81 // CHECK-NEXT: {
82 // CHECK-NEXT: "clang-module-deps": [],
83 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/third/module.modulemap",
84 // CHECK-NEXT: "command-line": [
85 // CHECK-NEXT: "-cc1",
86 // CHECK-NOT: "-fmodule-map-file=
87 // CHECK-NOT: "-fmodule-file=third=
88 // CHECK: ],
89 // CHECK-NEXT: "context-hash": "{{.*}}",
90 // CHECK-NEXT: "file-deps": [
91 // CHECK-NEXT: "[[PREFIX]]/third/module.modulemap"
92 // CHECK-NEXT: ],
93 // CHECK-NEXT: "name": "third"
94 // CHECK-NEXT: }
95 // CHECK-NEXT: ],
96 // CHECK-NEXT: "translation-units": [
97 // CHECK-NEXT: {
98 // CHECK-NEXT: "commands": [
99 // CHECK-NEXT: {
100 // CHECK-NEXT: "clang-context-hash": "{{.*}}",
101 // CHECK-NEXT: "clang-module-deps": [
102 // CHECK-NEXT: {
103 // CHECK-NEXT: "context-hash": "{{.*}}",
104 // CHECK-NEXT: "module-name": "first"
105 // CHECK-NEXT: }
106 // CHECK-NEXT: ],
107 // CHECK-NEXT: "command-line": [
108 // CHECK-NEXT: "-cc1",
109 // CHECK: "-fmodule-map-file=[[PREFIX]]/first/first/module.modulemap",
110 // CHECK: "-fmodule-file=first=[[PREFIX]]/cache/{{.*}}/first-{{.*}}.pcm",
111 // CHECK: ],
112 // CHECK-NEXT: "executable": "clang",
113 // CHECK-NEXT: "file-deps": [
114 // CHECK-NEXT: "[[PREFIX]]/tu.m"
115 // CHECK-NEXT: ],
116 // CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"
117 // CHECK-NEXT: }
118 // CHECK: ]
119 // CHECK: }
120 // CHECK: ]
121 // CHECK: }
123 // RUN: %deps-to-rsp %t/result.json --module-name=third > %t/third.cc1.rsp
124 // RUN: %deps-to-rsp %t/result.json --module-name=second > %t/second.cc1.rsp
125 // RUN: %deps-to-rsp %t/result.json --module-name=first > %t/first.cc1.rsp
126 // RUN: %clang @%t/third.cc1.rsp
127 // RUN: %clang @%t/second.cc1.rsp
128 // RUN: %clang @%t/first.cc1.rsp