@@ -605,7 +605,8 @@ struct SwiftASTManager::Implementation {
605
605
606
606
BufferStamp
607
607
getBufferStamp (StringRef FilePath,
608
- IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem) const ;
608
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
609
+ bool CheckEditorDocs = true ) const ;
609
610
610
611
std::unique_ptr<llvm::MemoryBuffer>
611
612
getMemoryBuffer (StringRef Filename,
@@ -793,24 +794,29 @@ FileContentRef SwiftASTManager::Implementation::getFileContent(
793
794
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
794
795
std::string &Error) const {
795
796
std::string FilePath = SwiftLangSupport::resolvePathSymlinks (UnresolvedPath);
796
- if (auto EditorDoc = EditorDocs->findByPath (FilePath))
797
+ if (auto EditorDoc = EditorDocs->findByPath (FilePath, /* IsRealpath= */ true ))
797
798
return getFileContentFromSnap (EditorDoc->getLatestSnapshot (), IsPrimary,
798
799
FilePath);
799
800
800
801
// FIXME: Is there a way to get timestamp and buffer for a file atomically ?
801
- auto Stamp = getBufferStamp (FilePath, FileSystem);
802
+ // No need to check EditorDocs again. We did so above.
803
+ auto Stamp = getBufferStamp (FilePath, FileSystem, /* CheckEditorDocs=*/ false );
802
804
auto Buffer = getMemoryBuffer (FilePath, FileSystem, Error);
803
805
return new FileContent (nullptr , UnresolvedPath.str (), std::move (Buffer),
804
806
IsPrimary, Stamp);
805
807
}
806
808
807
809
BufferStamp SwiftASTManager::Implementation::getBufferStamp (
808
810
StringRef FilePath,
809
- llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem) const {
811
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
812
+ bool CheckEditorDocs) const {
810
813
assert (FileSystem);
811
814
812
- if (auto EditorDoc = EditorDocs->findByPath (FilePath))
813
- return EditorDoc->getLatestSnapshot ()->getStamp ();
815
+ if (CheckEditorDocs) {
816
+ if (auto EditorDoc = EditorDocs->findByPath (FilePath)) {
817
+ return EditorDoc->getLatestSnapshot ()->getStamp ();
818
+ }
819
+ }
814
820
815
821
auto StatusOrErr = FileSystem->status (FilePath);
816
822
if (std::error_code Err = StatusOrErr.getError ()) {
0 commit comments