mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
thread a vfs through the completion handler
This commit is contained in:
@@ -195,9 +195,14 @@ bool CompilerInstance::setUpASTContextIfNeeded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CompilerInstance::setup(const CompilerInvocation &Invok) {
|
||||
bool CompilerInstance::setup(
|
||||
const CompilerInvocation &Invok,
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) {
|
||||
Invocation = Invok;
|
||||
|
||||
if (BaseFS)
|
||||
SourceMgr.setFileSystem(BaseFS);
|
||||
|
||||
// If initializing the overlay file system fails there's no sense in
|
||||
// continuing because the compiler will read the wrong files.
|
||||
if (setUpVirtualFileSystemOverlays())
|
||||
@@ -256,19 +261,20 @@ static bool loadAndValidateVFSOverlay(
|
||||
}
|
||||
|
||||
bool CompilerInstance::setUpVirtualFileSystemOverlays() {
|
||||
auto BaseFS = llvm::vfs::getRealFileSystem();
|
||||
auto BaseFS = SourceMgr.getFileSystem();
|
||||
auto OverlayFS = llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>(
|
||||
new llvm::vfs::OverlayFileSystem(BaseFS));
|
||||
bool hadAnyFailure = false;
|
||||
bool hasOverlays = false;
|
||||
for (const auto &File : Invocation.getSearchPathOptions().VFSOverlayFiles) {
|
||||
hasOverlays = true;
|
||||
hadAnyFailure |=
|
||||
loadAndValidateVFSOverlay(File, BaseFS, OverlayFS, Diagnostics);
|
||||
}
|
||||
|
||||
// If we successfully loaded all the overlays, let the source manager and
|
||||
// diagnostic engine take advantage of the overlay file system.
|
||||
if (!hadAnyFailure &&
|
||||
(OverlayFS->overlays_begin() != OverlayFS->overlays_end())) {
|
||||
if (!hadAnyFailure && hasOverlays) {
|
||||
SourceMgr.setFileSystem(OverlayFS);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user