Debian Codegraph @

clang/test/ClangScanDeps/modules-file-path-isolation.c

raw
1 // Ensure that the spelling of a path seen outside a module (e.g. header via
2 // symlink) does not leak into the compilation of that module unnecessarily.
3 // Note: the spelling of the modulemap path still depends on the includer, since
4 // that is the only source of information about it.
5
6 // REQUIRES: shell
7
8 // RUN: rm -rf %t
9 // RUN: split-file %s %t
10 // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json
11 // RUN: ln -s A.h %t/Z.h
12
13 // RUN: clang-scan-deps -compilation-database %t/cdb.json -j 1 -format experimental-full \
14 // RUN: -mode preprocess-dependency-directives > %t/output
15 // RUN: FileCheck %s < %t/output
16
17 // CHECK: "modules": [
18 // CHECK-NEXT: {
19 // CHECK: "file-deps": [
20 // CHECK-NEXT: "{{.*}}A.h",
21 // CHECK-NEXT: "{{.*}}module.modulemap"
22 // CHECK-NEXT: ],
23 // CHECK-NEXT: "link-libraries": [],
24 // CHECK-NEXT: "name": "A"
25 // CHECK-NEXT: }
26
27 //--- cdb.json.in
28 [{
29 "directory": "DIR",
30 "command": "clang -fsyntax-only DIR/tu.c -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps",
31 "file": "DIR/tu.c"
32 }]
33
34 //--- module.modulemap
35 module A { header "A.h" }
36 module B { header "B.h" }
37 module C { header "C.h" }
38
39 //--- A.h
40
41 //--- B.h
42 #include "Z.h"
43
44 //--- tu.c
45 #include "B.h"