1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
// Ensure we get the virtual module map path for a module whose implementation
// file we are compiling.
// RUN: rm -rf %t
// RUN: split-file %s %t
//--- real/A.modulemap
framework module A { umbrella header "A.h" }
//--- real/A.private.modulemap
framework module A_Private { umbrella header "A_Private.h" }
//--- frameworks/A.framework/Headers/A.h
struct A { int x; };
//--- frameworks/A.framework/PrivateHeaders/A_Private.h
#import <A/A.h>
//--- frameworks/B.framework/Headers/B.h
#import <A/A.h>
//--- frameworks/B.framework/Modules/module.modulemap
framework module B { umbrella header "B.h" }
//--- overlay.json.template
{
"case-sensitive": "false",
"version": 0,
"roots": [
{
"external-contents": "DIR/real/A.modulemap",
"name": "DIR/frameworks/A.framework/Modules/module.modulemap",
"type": "file"
},
{
"external-contents": "DIR/real/A.private.modulemap",
"name": "DIR/frameworks/A.framework/Modules/module.private.modulemap",
"type": "file"
},
]
}
//--- cdb.json.template
[
{
"file": "DIR/tu1.m",
"directory": "DIR",
"command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu1.m"
},
{
"file": "DIR/tu2.m",
"directory": "DIR",
"command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu2.m"
},
{
"file": "DIR/tu3.m",
"directory": "DIR",
"command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu3.m"
}
]
//--- tu1.m
#import <A/A.h>
//--- tu2.m
#import <A/A_Private.h>
//--- tu3.m
#import <B/B.h>
// The following code triggers a note diagnostic pointing to A.h which is
// resolved relative to the module base directory, which is affected by the
// modulemap path.
struct A { float x; }; // expected-error {{incompatible definitions}} expected-note {{type 'float' here}}
// expected-note@frameworks/A.framework/Headers/A.h:1 {{type 'int' here}}
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
// RUN: sed -e "s|DIR|%/t|g" %t/overlay.json.template > %t/overlay.json
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -j 1 > %t/result.json
// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
// CHECK: {
// CHECK: "modules": [
// CHECK: {
// CHECK: "clang-module-deps": []
// CHECK: "command-line": [
// CHECK: "-x"
// CHECK-NEXT: "objective-c"
// CHECK-NEXT: "[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
// CHECK: ]
// CHECK: "name": "A"
// CHECK: }
// CHECK: {
// CHECK: "clang-module-deps": [
// CHECK: {
// CHECK: "module-name": "A"
// CHECK: }
// CHECK: ]
// CHECK: "command-line": [
// CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap",
// CHECK: "-x"
// CHECK-NEXT: "objective-c"
// CHECK-NEXT: "[[PREFIX]]/frameworks/B.framework/Modules/module.modulemap"
// CHECK: ]
// CHECK: "name": "B"
// CHECK: }
// CHECK: "translation-units": [
// CHECK-NEXT: {
// CHECK-NEXT: "commands": [
// CHECK: {
// CHECK: "command-line": [
// CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
// CHECK: "-fmodule-name=A"
// CHECK: ],
// CHECK: "input-file": "[[PREFIX]]/tu1.m"
// CHECK-NEXT: }
// CHECK: ]
// CHECK: }
// CHECK-NEXT: {
// CHECK-NEXT: "commands": [
// CHECK: {
// CHECK: "command-line": [
// CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
// CHECK: "-fmodule-name=A"
// CHECK: ],
// CHECK: "input-file": "[[PREFIX]]/tu2.m"
// CHECK-NEXT: }
// CHECK: ]
// CHECK: }
// CHECK-NEXT: {
// CHECK-NEXT: "commands": [
// CHECK: {
// CHECK: "clang-module-deps": [
// CHECK: {
// CHECK: "module-name": "B"
// CHECK: }
// CHECK: ]
// CHECK: "command-line": [
// CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
// CHECK: "-fmodule-map-file=[[PREFIX]]/frameworks/B.framework/Modules/module.modulemap"
// CHECK: "-fmodule-name=A"
// CHECK: ],
// CHECK: "input-file": "[[PREFIX]]/tu3.m"
// CHECK-NEXT: }
// CHECK: ]
// CHECK: }
// RUN: %deps-to-rsp %t/result.json --tu-index=0 > %t/tu1.rsp
// RUN: %clang @%t/tu1.rsp
// RUN: %deps-to-rsp %t/result.json --tu-index=1 > %t/tu2.rsp
// RUN: %clang @%t/tu2.rsp
// RUN: %deps-to-rsp %t/result.json --module-name A > %t/A.rsp
// RUN: %deps-to-rsp %t/result.json --module-name B > %t/B.rsp
// RUN: %deps-to-rsp %t/result.json --tu-index=2 > %t/tu3.rsp
// RUN: %clang @%t/A.rsp
// RUN: %clang @%t/B.rsp
// RUN: %clang @%t/tu3.rsp -verify
|