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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
// Check that tracking of VFSs works with PCH.
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: sed -e "s|DIR|%/t|g" %t/build/compile-commands-pch.json.in > %t/build/compile-commands-pch.json
// RUN: sed -e "s|DIR|%/t|g" %t/build/compile-commands-tu.json.in > %t/build/compile-commands-tu.json
// RUN: sed -e "s|DIR|%/t|g" %t/build/compile-commands-tu-no-vfs-error.json.in > %t/build/compile-commands-tu-no-vfs-error.json
// RUN: sed -e "s|DIR|%/t|g" %t/build/compile-commands-tu1.json.in > %t/build/compile-commands-tu1.json
// RUN: sed -e "s|DIR|%/t|g" %t/build/pch-overlay.yaml.in > %t/build/pch-overlay.yaml
// RUN: clang-scan-deps -compilation-database %t/build/compile-commands-pch.json \
// RUN: -j 1 -format experimental-full --optimize-args=vfs,header-search > %t/pch-deps.db
// RUN: %deps-to-rsp %t/pch-deps.db --module-name=A > %t/A.rsp
// RUN: %deps-to-rsp %t/pch-deps.db --module-name=B > %t/B.rsp
// RUN: %deps-to-rsp %t/pch-deps.db --tu-index=0 > %t/pch.rsp
// RUN: %clang @%t/A.rsp
// RUN: %clang @%t/B.rsp
// RUN: %clang @%t/pch.rsp
// RUN: clang-scan-deps -compilation-database %t/build/compile-commands-tu.json \
// RUN: -j 1 -format experimental-full --optimize-args=vfs,header-search > %t/tu-deps.db
// RUN: %deps-to-rsp %t/tu-deps.db --module-name=C > %t/C.rsp
// RUN: %deps-to-rsp %t/tu-deps.db --tu-index=0 > %t/tu.rsp
// RUN: %clang @%t/C.rsp
// RUN: %clang @%t/tu.rsp
// RUN: not clang-scan-deps -compilation-database %t/build/compile-commands-tu-no-vfs-error.json \
// RUN: -j 1 -format experimental-full --optimize-args=vfs,header-search 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
// CHECK-ERROR: error: PCH was compiled with different VFS overlay files than are currently in use
// CHECK-ERROR: note: current translation unit has no VFS overlays
// Next test is to verify that a module that doesn't use the VFS, that depends
// on the PCH's A, which does use the VFS, still records that it needs the VFS.
// This avoids a fatal error when emitting diagnostics.
// RUN: clang-scan-deps -compilation-database %t/build/compile-commands-tu1.json \
// RUN: -j 1 -format experimental-full --optimize-args=vfs,header-search > %t/tu1-deps.db
// RUN: %deps-to-rsp %t/tu1-deps.db --tu-index=0 > %t/tu1.rsp
// Reuse existing B
// RUN: %deps-to-rsp %t/tu1-deps.db --module-name=E > %t/E.rsp
// RUN: %deps-to-rsp %t/tu1-deps.db --module-name=D > %t/D.rsp
// The build of D depends on B which depend on the prebuilt A. D will only build
// if it has A's VFS, as it needs to emit a diagnostic showing the content of A.
// RUN: %clang @%t/E.rsp
// RUN: %clang @%t/D.rsp -verify
// RUN: %clang @%t/tu1.rsp
// RUN: cat %t/tu1-deps.db | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
// Check that D has the overlay, but E doesn't.
// CHECK: {
// CHECK-NEXT: "modules": [
// CHECK-NEXT: {
// CHECK-NEXT: "clang-module-deps": [
// CHECK-NEXT: {
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "module-name": "E"
// CHECK-NEXT: }
// CHECK-NEXT: ],
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/modules/D/module.modulemap",
// CHECK-NEXT: "command-line": [
// CHECK: "-ivfsoverlay"
// CHECK-NEXT: "[[PREFIX]]/build/pch-overlay.yaml"
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
// CHECK-NEXT: "{{.*}}"
// CHECK-NEXT: "{{.*}}"
// CHECK-NEXT: "{{.*}}"
// CHECK-NEXT: "{{.*}}"
// CHECK-NEXT: ],
// CHECK: "name": "D"
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "clang-module-deps": [],
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/modules/E/module.modulemap",
// CHECK-NEXT: "command-line": [
// CHECK-NOT: "-ivfsoverlay"
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
// CHECK-NEXT: "{{.*}}"
// CHECK-NEXT: "{{.*}}"
// CHECK-NEXT: ],
// CHECK: "name": "E"
// CHECK-NEXT: }
//--- build/compile-commands-pch.json.in
[
{
"directory": "DIR",
"command": "clang -x objective-c-header DIR/pch.h -I DIR/modules/A -I DIR/modules/B -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -o DIR/pch.h.pch -ivfsoverlay DIR/build/pch-overlay.yaml",
"file": "DIR/pch.h"
}
]
//--- build/compile-commands-tu.json.in
[
{
"directory": "DIR",
"command": "clang -fsyntax-only DIR/tu.m -I DIR/modules/A -I DIR/modules/B -I DIR/modules/C -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/pch.h -o DIR/tu.o -ivfsoverlay DIR/build/pch-overlay.yaml",
"file": "DIR/tu.m"
}
]
//--- build/compile-commands-tu-no-vfs-error.json.in
[
{
"directory": "DIR",
"command": "clang -Wpch-vfs-diff -Werror=pch-vfs-diff -fsyntax-only DIR/tu.m -I DIR/modules/A -I DIR/modules/B -I DIR/modules/C -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/pch.h -o DIR/tu.o",
"file": "DIR/tu.m"
}
]
//--- build/compile-commands-tu1.json.in
[
{
"directory": "DIR",
"command": "clang -fsyntax-only DIR/tu1.m -I DIR/modules/B -I DIR/modules/D -I DIR/modules/E -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/pch.h -o DIR/tu1.o -ivfsoverlay DIR/build/pch-overlay.yaml",
"file": "DIR/tu1.m"
}
]
//--- build/pch-overlay.yaml.in
{
"version":0,
"case-sensitive":"false",
"roots":[
{
"contents":[
{
"external-contents":"DIR/build/module.modulemap",
"name":"module.modulemap",
"type":"file"
},
{
"external-contents":"DIR/build/A.h",
"name":"A.h",
"type":"file"
}
],
"name":"DIR/modules/A",
"type":"directory"
}
]
}
//--- pch.h
#include <B.h>
//--- build/module.modulemap
module A {
umbrella header "A.h"
}
//--- build/A.h
typedef int A_t __attribute__((deprecated("yep, it's depr")));
//--- modules/B/module.modulemap
module B {
umbrella header "B.h"
export *
}
//--- modules/B/B.h
#include <A.h>
typedef int B_t;
//--- modules/C/module.modulemap
module C {
umbrella header "C.h"
}
//--- modules/C/C.h
#include <B.h>
typedef int C_t;
//--- tu.m
#include <C.h>
A_t a = 0;
B_t b = 0;
C_t c = 0;
//--- modules/D/module.modulemap
module D {
umbrella header "D.h"
export *
}
//--- modules/D/D.h
#include <B.h>
#include <E.h>
typedef A_t D_t; // expected-warning{{'A_t' is deprecated}}
// expected-note@*:* {{marked deprecated here}}
//--- modules/E/module.modulemap
module E {
umbrella header "E.h"
}
//--- modules/E/E.h
typedef int E_t;
//--- tu1.m
#include <D.h>
D_t d = 0;
E_t e = 0;
|