1 // This test checks that modules loaded during compilation (but not imported)
2 // are still reported as dependencies.
4 // RUN: rm -rf %t && mkdir %t
5 // RUN: split-file %s %t
7 //--- frameworks/FW.framework/Modules/module.modulemap
12 //--- frameworks/FW.framework/Headers/FW.h
13 //--- frameworks/FW.framework/Modules/module.private.modulemap
14 framework module FW_Private
{
15 umbrella header
"FW_Private.h"
18 //--- frameworks/FW.framework/PrivateHeaders/FW_Private.h
20 //--- frameworks/FW.framework/PrivateHeaders/One.h
21 //--- frameworks/FW.framework/PrivateHeaders/Two.h
23 // Let's check we report the non-imported modular dependencies for a translation unit.
25 //--- from_tu.cdb.json.template
27 "file": "DIR/from_tu.m",
29 "command": "clang -fmodules -fmodules-cache-path=DIR/cache -F DIR/frameworks -c DIR/from_tu.m -o DIR/from_tu.o"
35 // RUN: sed -e "s|DIR|%/t|g" %t/from_tu.cdb.json.template > %t/from_tu.cdb.json
36 // RUN: clang-scan-deps -compilation-database %t/from_tu.cdb.json -format experimental-full > %t/from_tu_result.json
37 // RUN: cat %t/from_tu_result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK_TU
39 // CHECK_TU-NEXT: "modules": [
41 // CHECK_TU-NEXT: "clang-module-deps": [],
42 // CHECK_TU-NEXT: "clang-modulemap-file": "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
43 // CHECK_TU-NEXT: "command-line": [
45 // CHECK_TU-NEXT: "context-hash": "{{.*}}",
46 // CHECK_TU-NEXT: "file-deps": [
47 // CHECK_TU-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h",
48 // CHECK_TU-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap"
50 // CHECK_TU-NEXT: "name": "FW"
53 // CHECK_TU-NEXT: "clang-module-deps": [],
54 // CHECK_TU-NEXT: "clang-modulemap-file": "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
55 // CHECK_TU-NEXT: "command-line": [
57 // CHECK_TU-NEXT: "context-hash": "{{.*}}",
58 // CHECK_TU-NEXT: "file-deps": [
59 // CHECK_TU-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
60 // CHECK_TU-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/FW_Private.h",
61 // CHECK_TU-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/One.h"
63 // CHECK_TU-NEXT: "name": "FW_Private"
66 // CHECK_TU-NEXT: "translation-units": [
68 // CHECK_TU: "clang-context-hash": "{{.*}}",
69 // CHECK_TU-NEXT: "clang-module-deps": [
71 // CHECK_TU-NEXT: "context-hash": "{{.*}}",
72 // CHECK_TU-NEXT: "module-name": "FW"
75 // CHECK_TU-NEXT: "context-hash": "{{.*}}",
76 // CHECK_TU-NEXT: "module-name": "FW_Private"
79 // CHECK_TU-NEXT: "command-line": [
80 // CHECK_TU: "-fmodule-file={{.*}}/FW-{{.*}}.pcm"
81 // CHECK_TU: "-fmodule-file={{.*}}/FW_Private-{{.*}}.pcm"
83 // CHECK_TU: "file-deps": [
84 // CHECK_TU-NEXT: "[[PREFIX]]/from_tu.m",
85 // CHECK_TU-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/Two.h"
87 // CHECK_TU-NEXT: "input-file": "[[PREFIX]]/from_tu.m"
90 // RUN: %deps-to-rsp %t/from_tu_result.json --module-name=FW > %t/FW.cc1.rsp
91 // RUN: %deps-to-rsp %t/from_tu_result.json --module-name=FW_Private > %t/FW_Private.cc1.rsp
92 // RUN: %deps-to-rsp %t/from_tu_result.json --tu-index=0 > %t/tu.rsp
93 // RUN: %clang @%t/FW.cc1.rsp
94 // RUN: %clang @%t/FW_Private.cc1.rsp
95 // RUN: %clang @%t/tu.rsp
97 // Now let's check we report the dependencies for modules as well.
99 //--- from_module.cdb.json.template
101 "file": "DIR/from_module.m",
103 "command": "clang -fmodules -fmodules-cache-path=DIR/cache -F DIR/frameworks -c DIR/from_module.m -o DIR/from_module.o"
105 //--- module.modulemap
106 module Mod
{ header
"Mod.h" }
113 // RUN: sed -e "s|DIR|%/t|g" %t/from_module.cdb.json.template > %t/from_module.cdb.json
114 // RUN: clang-scan-deps -compilation-database %t/from_module.cdb.json -format experimental-full > %t/from_module_result.json
115 // RUN: cat %t/from_module_result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK_MODULE
117 // CHECK_MODULE-NEXT: "modules": [
118 // CHECK_MODULE-NEXT: {
119 // CHECK_MODULE-NEXT: "clang-module-deps": [],
120 // CHECK_MODULE-NEXT: "clang-modulemap-file": "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
121 // CHECK_MODULE-NEXT: "command-line": [
123 // CHECK_MODULE-NEXT: "context-hash": "{{.*}}",
124 // CHECK_MODULE-NEXT: "file-deps": [
125 // CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h",
126 // CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap"
127 // CHECK_MODULE-NEXT: ],
128 // CHECK_MODULE-NEXT: "name": "FW"
129 // CHECK_MODULE-NEXT: },
130 // CHECK_MODULE-NEXT: {
131 // CHECK_MODULE-NEXT: "clang-module-deps": [],
132 // CHECK_MODULE-NEXT: "clang-modulemap-file": "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
133 // CHECK_MODULE-NEXT: "command-line": [
135 // CHECK_MODULE-NEXT: "context-hash": "{{.*}}",
136 // CHECK_MODULE-NEXT: "file-deps": [
137 // CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
138 // CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/FW_Private.h",
139 // CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/One.h"
140 // CHECK_MODULE-NEXT: ],
141 // CHECK_MODULE-NEXT: "name": "FW_Private"
142 // CHECK_MODULE-NEXT: },
143 // CHECK_MODULE-NEXT: {
144 // CHECK_MODULE-NEXT: "clang-module-deps": [
145 // CHECK_MODULE-NEXT: {
146 // CHECK_MODULE-NEXT: "context-hash": "{{.*}}",
147 // CHECK_MODULE-NEXT: "module-name": "FW"
148 // CHECK_MODULE-NEXT: },
149 // CHECK_MODULE-NEXT: {
150 // CHECK_MODULE-NEXT: "context-hash": "{{.*}}",
151 // CHECK_MODULE-NEXT: "module-name": "FW_Private"
152 // CHECK_MODULE-NEXT: }
153 // CHECK_MODULE-NEXT: ],
154 // CHECK_MODULE-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
155 // CHECK_MODULE-NEXT: "command-line": [
156 // CHECK_MODULE: "-fmodule-file={{.*}}/FW-{{.*}}.pcm"
157 // CHECK_MODULE: "-fmodule-file={{.*}}/FW_Private-{{.*}}.pcm"
159 // CHECK_MODULE-NEXT: "context-hash": "{{.*}}",
160 // CHECK_MODULE-NEXT: "file-deps": [
161 // CHECK_MODULE-NEXT: "[[PREFIX]]/Mod.h"
162 // CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
163 // CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
164 // CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/Two.h",
165 // CHECK_MODULE-NEXT: "[[PREFIX]]/module.modulemap"
166 // CHECK_MODULE-NEXT: ],
167 // CHECK_MODULE-NEXT: "name": "Mod"
168 // CHECK_MODULE-NEXT: }
169 // CHECK_MODULE-NEXT: ],
170 // CHECK_MODULE-NEXT: "translation-units": [
171 // CHECK_MODULE-NEXT: {
172 // CHECK_MODULE: "clang-context-hash": "{{.*}}",
173 // CHECK_MODULE-NEXT: "clang-module-deps": [
174 // CHECK_MODULE-NEXT: {
175 // CHECK_MODULE-NEXT: "context-hash": "{{.*}}",
176 // CHECK_MODULE-NEXT: "module-name": "Mod"
177 // CHECK_MODULE-NEXT: }
178 // CHECK_MODULE-NEXT: ],
179 // CHECK_MODULE-NEXT: "command-line": [
181 // CHECK_MODULE: "file-deps": [
182 // CHECK_MODULE-NEXT: "[[PREFIX]]/from_module.m"
183 // CHECK_MODULE-NEXT: ],
184 // CHECK_MODULE-NEXT: "input-file": "[[PREFIX]]/from_module.m"
185 // CHECK_MODULE-NEXT: }
187 // RUN: %deps-to-rsp %t/from_module_result.json --module-name=FW > %t/FW.cc1.rsp
188 // RUN: %deps-to-rsp %t/from_module_result.json --module-name=FW_Private > %t/FW_Private.cc1.rsp
189 // RUN: %deps-to-rsp %t/from_module_result.json --module-name=Mod > %t/Mod.cc1.rsp
190 // RUN: %deps-to-rsp %t/from_module_result.json --tu-index=0 > %t/tu.rsp
191 // RUN: %clang @%t/FW.cc1.rsp
192 // RUN: %clang @%t/FW_Private.cc1.rsp
193 // RUN: %clang @%t/Mod.cc1.rsp
194 // RUN: %clang @%t/tu.rsp