197 lines · plain
1// RUN: rm -rf %t2// RUN: split-file %s %t3// RUN: sed -e "s|DIR|%/t|g" %t/build/compile-commands.json.in > %t/build/compile-commands.json4// RUN: sed -e "s|DIR|%/t|g" %t/build/vfs.yaml.in > %t/build/vfs.yaml5// RUN: sed -e "s|DIR|%/t|g" %t/build/unused-vfs.yaml.in > %t/build/unused-vfs.yaml6// RUN: sed -e "s|DIR|%/t|g" %t/build/unused-vfs.yaml.in > %t/build/unused2-vfs.yaml7// RUN: clang-scan-deps -compilation-database %t/build/compile-commands.json \8// RUN: -j 1 -format experimental-full --optimize-args=vfs,header-search > %t/deps.db9// RUN: cat %t/deps.db | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t10 11// Check that unused -ivfsoverlay arguments are removed, and that used ones are12// not.13 14// CHECK: {15// CHECK-NEXT: "modules": [16// CHECK-NEXT: {17// CHECK-NEXT: "clang-module-deps": [],18// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/modules/A/module.modulemap",19// CHECK-NEXT: "command-line": [20// CHECK-NOT: "build/unused-vfs.yaml"21// CHECK: "-ivfsoverlay"22// CHECK-NEXT: "build/vfs.yaml"23// CHECK-NOT: "build/unused-vfs.yaml"24// CHECK: ],25// CHECK-NEXT: "context-hash": "{{.*}}",26// CHECK-NEXT: "file-deps": [27// CHECK-NEXT: "[[PREFIX]]/build/module.modulemap",28// CHECK-NEXT: "[[PREFIX]]/build/A.h"29// CHECK-NEXT: ],30// CHECK-NEXT: "link-libraries": [],31// CHECK-NEXT: "name": "A"32// CHECK-NEXT: },33// CHECK-NEXT: {34// CHECK-NEXT: "clang-module-deps": [],35// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/modules/B/module.modulemap",36// CHECK-NEXT: "command-line": [37// CHECK-NOT: "-ivfsoverlay"38// CHECK: ],39// CHECK-NEXT: "context-hash": "{{.*}}",40// CHECK-NEXT: "file-deps": [41// CHECK-NEXT: "[[PREFIX]]/modules/B/module.modulemap",42// CHECK-NEXT: "[[PREFIX]]/modules/B/B.h"43// CHECK-NEXT: ],44// CHECK-NEXT: "link-libraries": [],45// CHECK-NEXT: "name": "B"46// CHECK-NEXT: },47// CHECK-NEXT: {48// CHECK-NEXT: "clang-module-deps": [49// CHECK-NEXT: {50// CHECK-NEXT: "context-hash": "{{.*}}",51// CHECK-NEXT: "module-name": "B"52// CHECK-NEXT: }53// CHECK-NEXT: ],54// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/modules/C/module.modulemap",55// CHECK-NEXT: "command-line": [56// CHECK-NOT: "-ivfsoverlay"57// CHECK: ],58// CHECK-NEXT: "context-hash": "{{.*}}",59// CHECK-NEXT: "file-deps": [60// CHECK-NEXT: "[[PREFIX]]/modules/C/module.modulemap",61// CHECK-NEXT: "[[PREFIX]]/modules/C/C.h",62// CHECK-NEXT: "[[PREFIX]]/modules/B/module.modulemap"63// CHECK-NEXT: ],64// CHECK-NEXT: "link-libraries": [],65// CHECK-NEXT: "name": "C"66// CHECK-NEXT: }67// CHECK-NEXT: ],68// CHECK-NEXT: "translation-units": [69// CHECK: ]70// CHECK: }71 72//--- build/compile-commands.json.in73 74[75{76 "directory": "DIR",77 "command": "clang -c DIR/0.m -Imodules/A -Imodules/B -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -ivfsoverlay build/unused-vfs.yaml -ivfsoverlay build/unused2-vfs.yaml -ivfsoverlay build/vfs.yaml",78 "file": "DIR/0.m"79},80{81 "directory": "DIR",82 "command": "clang -c DIR/A.m -Imodules/A -Imodules/B -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -ivfsoverlay build/vfs.yaml -ivfsoverlay build/unused-vfs.yaml",83 "file": "DIR/A.m"84},85{86 "directory": "DIR",87 "command": "clang -c DIR/B.m -Imodules/B -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -ivfsoverlay build/unused-vfs.yaml -ivfsoverlay build/vfs.yaml",88 "file": "DIR/B.m"89},90{91 "directory": "DIR",92 "command": "clang -c DIR/C.m -Imodules/A -Imodules/B -Imodules/C -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -ivfsoverlay build/vfs.yaml -ivfsoverlay build/unused-vfs.yaml",93 "file": "DIR/C.m"94}95]96 97//--- build/vfs.yaml.in98 99{100 "version":0,101 "case-sensitive":"false",102 "roots":[103 {104 "contents":[105 {106 "external-contents":"DIR/build/module.modulemap",107 "name":"module.modulemap",108 "type":"file"109 },110 {111 "external-contents":"DIR/build/A.h",112 "name":"A.h",113 "type":"file"114 }115 ],116 "name":"DIR/modules/A",117 "type":"directory"118 }119 ]120}121 122//--- build/unused-vfs.yaml.in123 124{125 "version":0,126 "case-sensitive":"false",127 "roots":[128 {129 "contents":[130 {131 "external-contents":"DIR/build/module.modulemap",132 "name":"module.modulemap",133 "type":"file"134 }135 ],136 "name":"DIR/modules/D",137 "type":"directory"138 }139 ]140}141 142//--- build/module.modulemap143 144module A {145 umbrella header "A.h"146}147 148//--- build/A.h149 150typedef int A_t;151 152//--- modules/B/module.modulemap153 154module B {155 umbrella header "B.h"156}157 158//--- modules/B/B.h159 160typedef int B_t;161 162//--- modules/C/module.modulemap163 164module C {165 umbrella header "C.h"166}167 168//--- modules/C/C.h169 170@import B;171 172typedef B_t C_t;173 174//--- 0.m175 176#include <A.h>177 178A_t a = 0;179 180//--- A.m181 182#include <A.h>183 184A_t a = 0;185 186//--- B.m187 188#include <B.h>189 190B_t b = 0;191 192//--- C.m193 194#include <C.h>195 196C_t b = 0;197