1 // Ensure we get the virtual module map path for a module whose implementation
2 // file we are compiling.
5 // RUN: split-file %s %t
8 framework module A { umbrella header "A.h" }
9 //--- real/A.private.modulemap
10 framework module A_Private { umbrella header "A_Private.h" }
12 //--- frameworks/A.framework/Headers/A.h
14 //--- frameworks/A.framework/PrivateHeaders/A_Private.h
17 //--- frameworks/B.framework/Headers/B.h
19 //--- frameworks/B.framework/Modules/module.modulemap
20 framework module B { umbrella header "B.h" }
22 //--- overlay.json.template
24 "case-sensitive": "false",
28 "external-contents": "DIR/real/A.modulemap",
29 "name": "DIR/frameworks/A.framework/Modules/module.modulemap",
33 "external-contents": "DIR/real/A.private.modulemap",
34 "name": "DIR/frameworks/A.framework/Modules/module.private.modulemap",
40 //--- cdb.json.template
45 "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu1.m"
50 "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu2.m"
55 "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu3.m"
63 #import <A/A_Private.h>
67 // The following code triggers a note diagnostic pointing to A.h which is
68 // resolved relative to the module base directory, which is affected by the
70 struct A { float x; }; // expected-error {{incompatible definitions}} expected-note {{type 'float' here}}
71 // expected-note@frameworks/A.framework/Headers/A.h:1 {{type 'int' here}}
73 // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
74 // RUN: sed -e "s|DIR|%/t|g" %t/overlay.json.template > %t/overlay.json
76 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -j 1 > %t/result.json
77 // RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
79 // CHECK: "modules": [
81 // CHECK: "clang-module-deps": []
82 // CHECK: "command-line": [
84 // CHECK-NEXT: "objective-c"
85 // CHECK-NEXT: "[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
90 // CHECK: "clang-module-deps": [
92 // CHECK: "module-name": "A"
95 // CHECK: "command-line": [
96 // CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap",
98 // CHECK-NEXT: "objective-c"
99 // CHECK-NEXT: "[[PREFIX]]/frameworks/B.framework/Modules/module.modulemap"
101 // CHECK: "name": "B"
104 // CHECK: "translation-units": [
106 // CHECK-NEXT: "commands": [
108 // CHECK: "command-line": [
109 // CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
110 // CHECK: "-fmodule-name=A"
112 // CHECK: "input-file": "[[PREFIX]]/tu1.m"
117 // CHECK-NEXT: "commands": [
119 // CHECK: "command-line": [
120 // CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
121 // CHECK: "-fmodule-name=A"
123 // CHECK: "input-file": "[[PREFIX]]/tu2.m"
128 // CHECK-NEXT: "commands": [
130 // CHECK: "clang-module-deps": [
132 // CHECK: "module-name": "B"
135 // CHECK: "command-line": [
136 // CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
137 // CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/B.framework/Modules/module.modulemap"
138 // CHECK: "-fmodule-name=A"
140 // CHECK: "input-file": "[[PREFIX]]/tu3.m"
145 // RUN: %deps-to-rsp %t/result.json --tu-index=0 > %t/tu1.rsp
146 // RUN: %clang @%t/tu1.rsp
148 // RUN: %deps-to-rsp %t/result.json --tu-index=1 > %t/tu2.rsp
149 // RUN: %clang @%t/tu2.rsp
151 // RUN: %deps-to-rsp %t/result.json --module-name A > %t/A.rsp
152 // RUN: %deps-to-rsp %t/result.json --module-name B > %t/B.rsp
153 // RUN: %deps-to-rsp %t/result.json --tu-index=2 > %t/tu3.rsp
154 // RUN: %clang @%t/A.rsp
155 // RUN: %clang @%t/B.rsp
156 // RUN: %clang @%t/tu3.rsp -verify