1 // This test checks that VFS usage doesn't leak between modules.
3 // RUN: rm -rf %t && split-file %s %t
4 // RUN: sed -e "s|DIR|%/t|g" %t/build/cdb.json.in > %t/build/cdb.json
5 // RUN: sed -e "s|DIR|%/t|g" %t/build/vfs.yaml.in > %t/build/vfs.yaml
6 // RUN: clang-scan-deps -compilation-database %t/build/cdb.json \
7 // RUN: -format experimental-full --optimize-args=vfs > %t/deps.json
8 // RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
11 // CHECK-NEXT: "modules": [
13 // CHECK-NEXT: "clang-module-deps": [
15 // CHECK-NEXT: "context-hash": "{{.*}}",
16 // CHECK-NEXT: "module-name": "B"
19 // CHECK-NEXT: "context-hash": "{{.*}}",
20 // CHECK-NEXT: "module-name": "C"
23 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/moduleA/module.modulemap",
24 // CHECK-NEXT: "command-line": [
25 // Module A needs the VFS overlay because its dependency, module B, needs it.
26 // CHECK: "-ivfsoverlay"
27 // CHECK-NEXT: "[[PREFIX]]/build/vfs.yaml"
29 // CHECK-NEXT: "context-hash": "{{.*}}",
30 // CHECK-NEXT: "file-deps": [
32 // CHECK-NEXT: "link-libraries": [],
33 // CHECK-NEXT: "name": "A"
36 // CHECK-NEXT: "clang-module-deps": [],
37 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/moduleB/module.modulemap",
38 // CHECK-NEXT: "command-line": [
39 // Module B needs the VFS overlay because it provides the header referred to by the module map.
40 // CHECK: "-ivfsoverlay"
41 // CHECK-NEXT: "[[PREFIX]]/build/vfs.yaml"
43 // CHECK-NEXT: "context-hash": "{{.*}}",
44 // CHECK-NEXT: "file-deps": [
46 // CHECK-NEXT: "link-libraries": [],
47 // CHECK-NEXT: "name": "B"
50 // CHECK-NEXT: "clang-module-deps": [],
51 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/moduleC/module.modulemap",
52 // CHECK-NEXT: "command-line": [
53 // Module C doesn't need the VFS overlay.
54 // CHECK-NOT: "-ivfsoverlay"
56 // CHECK-NEXT: "context-hash": "{{.*}}",
57 // CHECK-NEXT: "file-deps": [
59 // CHECK-NEXT: "link-libraries": [],
60 // CHECK-NEXT: "name": "C"
63 // CHECK-NEXT: "translation-units": [
67 //--- build/cdb.json.in
70 "command": "clang -c DIR/tu.m -I DIR/moduleA -I DIR/moduleB -I DIR/moduleC -fmodules -fmodules-cache-path=DIR/cache -fimplicit-module-maps -ivfsoverlay DIR/build/vfs.yaml",
74 //--- build/vfs.yaml.in
77 "case-sensitive": "false",
82 "external-contents": "DIR/build/B.h",
87 "name": "DIR/moduleB",
96 //--- moduleA/module.modulemap
97 module A { header "A.h" }
102 //--- moduleB/module.modulemap
103 module B { header "B.h" }
106 //--- moduleC/module.modulemap
107 module C { header "C.h" }