Skip to content

Commit c187300

Browse files
author
marcrasi
authored
fix SourceKit injected VFS with .swiftinterface files (#25093)
1 parent 46d5a2d commit c187300

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

include/swift/Frontend/Frontend.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,12 +518,6 @@ class CompilerInstance {
518518
/// Returns true if there was an error during setup.
519519
bool setup(const CompilerInvocation &Invocation);
520520

521-
/// Returns true if there was an error during setup.
522-
/// \param BaseFS Use this, instead of the real filesystem, as the vase
523-
/// filesystem.
524-
bool setup(const CompilerInvocation &Invocation,
525-
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);
526-
527521
private:
528522
/// Set up the file system by loading and validating all VFS overlay YAML
529523
/// files. If the process of validating VFS files failed, or the overlay

lib/Frontend/Frontend.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,8 @@ void CompilerInstance::recordPrimarySourceFile(SourceFile *SF) {
176176
}
177177

178178
bool CompilerInstance::setup(const CompilerInvocation &Invok) {
179-
return setup(Invok, llvm::vfs::getRealFileSystem());
180-
}
181-
182-
bool CompilerInstance::setup(
183-
const CompilerInvocation &Invok,
184-
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) {
185-
assert(BaseFS);
186179
Invocation = Invok;
187180

188-
SourceMgr.setFileSystem(BaseFS);
189-
190181
// If initializing the overlay file system fails there's no sense in
191182
// continuing because the compiler will read the wrong files.
192183
if (setUpVirtualFileSystemOverlays())
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import SwiftModule
2+
3+
func foo(
4+
_ structDefinedInSwiftModule: StructDefinedInSwiftModule
5+
) {
6+
structDefinedInSwiftModule.
7+
}
8+
9+
// CHECK: key.name: "methodDefinedInSwiftModule()"
10+
11+
// RUN: %empty-directory(%t)
12+
// 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
13+
// 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

tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,8 @@ ASTUnitRef ASTProducer::createASTUnit(SwiftASTManager::Implementation &MgrImpl,
927927

928928
Invocation.getLangOptions().CollectParsedToken = true;
929929

930-
if (CompIns.setup(Invocation, InvokRef->Impl.Opts.FileSystem)) {
930+
CompIns.getSourceMgr().setFileSystem(InvokRef->Impl.Opts.FileSystem);
931+
if (CompIns.setup(Invocation)) {
931932
// FIXME: Report the diagnostic.
932933
LOG_WARN_FUNC("Compilation setup failed!!!");
933934
Error = "compilation setup failed";

tools/SourceKit/lib/SwiftLang/SwiftCompletion.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ static bool swiftCodeCompleteImpl(
185185
// FIXME: We need to be passing the buffers from the open documents.
186186
// It is not a huge problem in practice because Xcode auto-saves constantly.
187187

188-
if (CI.setup(Invocation, FileSystem)) {
188+
CI.getSourceMgr().setFileSystem(FileSystem);
189+
if (CI.setup(Invocation)) {
189190
// FIXME: error?
190191
return true;
191192
}

0 commit comments

Comments
 (0)