Skip to content

Commit b2ed8a2

Browse files
authored
Merge pull request #41546 from bnbarham/use-overlay-fs-instead
[Importer] Wrap the VFS passed to Clang with an overlay FS instead
2 parents 10f3828 + bbc98aa commit b2ed8a2

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,7 @@ ClangImporter::create(ASTContext &ctx,
10991099

11001100
// Wrap Swift's FS to allow Clang to override the working directory
11011101
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
1102-
llvm::vfs::RedirectingFileSystem::create({}, true,
1103-
*ctx.SourceMgr.getFileSystem());
1102+
new llvm::vfs::OverlayFileSystem(ctx.SourceMgr.getFileSystem());
11041103

11051104
// Create a new Clang compiler invocation.
11061105
{
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file --leading-lines %s %t
3+
// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/A@g" -e "s@NAME_DIR@%{/t:regex_replacement}/B@g" %t/base.yaml > %t/overlay.yaml
4+
5+
//--- use.swift
6+
import MyMod
7+
8+
// RUN: %sourcekitd-test -req=cursor -pos=%(line+3):13 %t/use.swift -- -I%t/B -vfsoverlay %t/overlay.yaml %t/use.swift | %FileCheck --check-prefix=CHECK-A %s
9+
// RUN: %sourcekitd-test -req=cursor -pos=%(line+2):22 %t/use.swift -- -I%t/B -vfsoverlay %t/overlay.yaml %t/use.swift | %FileCheck --check-prefix=CHECK-B %s
10+
// RUN: %sourcekitd-test -req=cursor -pos=%(line+1):31 %t/use.swift -- -I%t/B -vfsoverlay %t/overlay.yaml %t/use.swift | %FileCheck --check-prefix=CHECK-C %s
11+
func f(arg: A, arg2: B, arg3: C) {}
12+
13+
//--- A/A.h
14+
// CHECK-A: source.lang.swift.ref.struct ({{.*}}{{/|\\}}A{{/|\\}}A.h:[[@LINE+1]]:8-[[@LINE+1]]:9)
15+
struct A {
16+
int a;
17+
};
18+
19+
//--- A/B.h
20+
21+
//--- A/C.h
22+
// CHECK-C: source.lang.swift.ref.struct ({{.*}}{{/|\\}}A{{/|\\}}C.h:[[@LINE+1]]:8-[[@LINE+1]]:9)
23+
struct C {
24+
int c;
25+
};
26+
27+
//--- B/B.h
28+
#include "C.h"
29+
30+
// CHECK-B: source.lang.swift.ref.struct ({{.*}}{{/|\\}}B{{/|\\}}B.h:[[@LINE+1]]:8-[[@LINE+1]]:9)
31+
struct B {
32+
int b;
33+
};
34+
35+
//--- B/module.modulemap
36+
module MyMod {
37+
header "A.h"
38+
header "B.h"
39+
}
40+
41+
//--- base.yaml
42+
{
43+
version: 0,
44+
redirecting-with: "fallback",
45+
use-external-names: true,
46+
roots: [
47+
{
48+
type: "directory-remap",
49+
name: "NAME_DIR",
50+
external-contents: "EXTERNAL_DIR"
51+
}
52+
]
53+
}
54+

0 commit comments

Comments
 (0)