1 // There are some edge-cases where Clang depends on knowing the module whose implementation it's currently building.
2 // This test makes sure scanner always reports the corresponding module map.
5 // RUN: split-file %s %t
7 //--- frameworks/A.framework/Modules/module.modulemap
8 framework module A { umbrella header "A.h" }
9 //--- frameworks/B.framework/Modules/module.modulemap
10 framework module B { umbrella header "B.h" }
11 //--- frameworks/A.framework/Headers/A.h
12 //--- frameworks/B.framework/Headers/B.h
13 //--- frameworks/A.framework/Modules/module.private.modulemap
14 framework module A_Private { umbrella header "A_Private.h" }
15 //--- frameworks/B.framework/Modules/module.private.modulemap
16 framework module B_Private { umbrella header "B_Private.h" }
17 //--- frameworks/A.framework/PrivateHeaders/A_Private.h
19 //--- frameworks/B.framework/PrivateHeaders/B_Private.h
24 //--- overlay.json.template
26 "case-sensitive": "false",
32 "external-contents": "DIR/shared/H.h",
37 "name": "DIR/frameworks/A.framework/PrivateHeaders",
43 "external-contents": "DIR/shared/H.h",
48 "name": "DIR/frameworks/B.framework/PrivateHeaders",
54 //--- cdb.json.template
58 "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -c DIR/tu.m -o DIR/tu.o"
66 // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
67 // RUN: sed -e "s|DIR|%/t|g" %t/overlay.json.template > %t/overlay.json
69 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json
70 // RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
72 // CHECK: "translation-units": [
74 // CHECK-NEXT: "commands": [
76 // CHECK: "command-line": [
77 // CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap",
78 // CHECK: "-fmodule-name=A",
80 // CHECK-NEXT: "executable": "clang",
81 // CHECK-NEXT: "file-deps": [
82 // CHECK-NEXT: "[[PREFIX]]/tu.m",
83 // CHECK-NEXT: "[[PREFIX]]/shared/H.h"
85 // CHECK-NEXT: "input-file": "[[PREFIX]]/tu.m"
90 // RUN: %deps-to-rsp %t/result.json --module-name=B > %t/B.cc1.rsp
91 // RUN: %clang @%t/B.cc1.rsp
93 // RUN: %deps-to-rsp %t/result.json --tu-index=0 > %t/tu.rsp
94 // RUN: %clang @%t/tu.rsp