@@ -605,7 +605,8 @@ struct SwiftASTManager::Implementation {
605605
606606 BufferStamp
607607 getBufferStamp (StringRef FilePath,
608- IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem) const ;
608+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
609+ bool CheckEditorDocs = true ) const ;
609610
610611 std::unique_ptr<llvm::MemoryBuffer>
611612 getMemoryBuffer (StringRef Filename,
@@ -793,24 +794,29 @@ FileContentRef SwiftASTManager::Implementation::getFileContent(
793794 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
794795 std::string &Error) const {
795796 std::string FilePath = SwiftLangSupport::resolvePathSymlinks (UnresolvedPath);
796- if (auto EditorDoc = EditorDocs->findByPath (FilePath))
797+ if (auto EditorDoc = EditorDocs->findByPath (FilePath, /* IsRealpath= */ true ))
797798 return getFileContentFromSnap (EditorDoc->getLatestSnapshot (), IsPrimary,
798799 FilePath);
799800
800801 // 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 );
802804 auto Buffer = getMemoryBuffer (FilePath, FileSystem, Error);
803805 return new FileContent (nullptr , UnresolvedPath.str (), std::move (Buffer),
804806 IsPrimary, Stamp);
805807}
806808
807809BufferStamp SwiftASTManager::Implementation::getBufferStamp (
808810 StringRef FilePath,
809- llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem) const {
811+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
812+ bool CheckEditorDocs) const {
810813 assert (FileSystem);
811814
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+ }
814820
815821 auto StatusOrErr = FileSystem->status (FilePath);
816822 if (std::error_code Err = StatusOrErr.getError ()) {
0 commit comments