fix SourceKit injected VFS with .swiftinterface files

Use `.setFileSystem()` instead of new `setup` method.
This commit is contained in:
marcrasi
2019-05-28 18:19:41 -07:00
committed by Marc Rasi
parent 840f4b90d9
commit eb8f384c01
5 changed files with 17 additions and 17 deletions

View File

@@ -518,12 +518,6 @@ public:
/// Returns true if there was an error during setup.
bool setup(const CompilerInvocation &Invocation);
/// Returns true if there was an error during setup.
/// \param BaseFS Use this, instead of the real filesystem, as the vase
/// filesystem.
bool setup(const CompilerInvocation &Invocation,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);
private:
/// Set up the file system by loading and validating all VFS overlay YAML
/// files. If the process of validating VFS files failed, or the overlay

View File

@@ -196,17 +196,8 @@ bool CompilerInstance::setUpASTContextIfNeeded() {
}
bool CompilerInstance::setup(const CompilerInvocation &Invok) {
return setup(Invok, llvm::vfs::getRealFileSystem());
}
bool CompilerInstance::setup(
const CompilerInvocation &Invok,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) {
assert(BaseFS);
Invocation = Invok;
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())

View File

@@ -0,0 +1,13 @@
import SwiftModule
func foo(
_ structDefinedInSwiftModule: StructDefinedInSwiftModule
) {
structDefinedInSwiftModule.
}
// CHECK: key.name: "methodDefinedInSwiftModule()"
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-parseable-module-interface-path %t/SwiftModule.swiftinterface -module-name SwiftModule -emit-module -o /dev/null %S/../Inputs/vfs/SwiftModule/SwiftModule.swift
// RUN: %sourcekitd-test -req=complete -pos=6:31 -vfs-files=/target_file1.swift=%s,/SwiftModule/SwiftModule.swiftinterface=%t/SwiftModule.swiftinterface /target_file1.swift -- /target_file1.swift -I /SwiftModule | %FileCheck %s

View File

@@ -936,7 +936,8 @@ ASTUnitRef ASTProducer::createASTUnit(SwiftASTManager::Implementation &MgrImpl,
Invocation.getLangOptions().CollectParsedToken = true;
if (CompIns.setup(Invocation, InvokRef->Impl.Opts.FileSystem)) {
CompIns.getSourceMgr().setFileSystem(InvokRef->Impl.Opts.FileSystem);
if (CompIns.setup(Invocation)) {
// FIXME: Report the diagnostic.
LOG_WARN_FUNC("Compilation setup failed!!!");
Error = "compilation setup failed";

View File

@@ -197,7 +197,8 @@ static bool swiftCodeCompleteImpl(
// FIXME: We need to be passing the buffers from the open documents.
// It is not a huge problem in practice because Xcode auto-saves constantly.
if (CI.setup(Invocation, FileSystem)) {
CI.getSourceMgr().setFileSystem(FileSystem);
if (CI.setup(Invocation)) {
// FIXME: error?
return true;
}