dexonsmith created this revision. dexonsmith added reviewers: jansvoboda11, JDevlieghere, arphaman. Herald added a subscriber: ributzka. dexonsmith requested review of this revision. Herald added a project: clang.
Use `FileManager::getVirtualFileRef` to get the virtual file for stdin, and add an overload of `SourceManager::overrideFileContents` that takes a `FileEntryRef`, migrating `CompilerInstance::InitializeSourceManager`. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D92680 Files: clang/include/clang/Basic/SourceManager.h clang/lib/Frontend/CompilerInstance.cpp Index: clang/lib/Frontend/CompilerInstance.cpp =================================================================== --- clang/lib/Frontend/CompilerInstance.cpp +++ clang/lib/Frontend/CompilerInstance.cpp @@ -869,8 +869,8 @@ } std::unique_ptr<llvm::MemoryBuffer> SB = std::move(SBOrErr.get()); - const FileEntry *File = FileMgr.getVirtualFile(SB->getBufferIdentifier(), - SB->getBufferSize(), 0); + FileEntryRef File = FileMgr.getVirtualFileRef(SB->getBufferIdentifier(), + SB->getBufferSize(), 0); SourceMgr.setMainFileID( SourceMgr.createFileID(File, SourceLocation(), Kind)); SourceMgr.overrideFileContents(File, std::move(SB)); Index: clang/include/clang/Basic/SourceManager.h =================================================================== --- clang/include/clang/Basic/SourceManager.h +++ clang/include/clang/Basic/SourceManager.h @@ -958,6 +958,10 @@ /// data in the given source file. void overrideFileContents(const FileEntry *SourceFile, std::unique_ptr<llvm::MemoryBuffer> Buffer); + void overrideFileContents(FileEntryRef SourceFile, + std::unique_ptr<llvm::MemoryBuffer> Buffer) { + overrideFileContents(&SourceFile.getFileEntry(), std::move(Buffer)); + } /// Override the given source file with another one. ///
Index: clang/lib/Frontend/CompilerInstance.cpp =================================================================== --- clang/lib/Frontend/CompilerInstance.cpp +++ clang/lib/Frontend/CompilerInstance.cpp @@ -869,8 +869,8 @@ } std::unique_ptr<llvm::MemoryBuffer> SB = std::move(SBOrErr.get()); - const FileEntry *File = FileMgr.getVirtualFile(SB->getBufferIdentifier(), - SB->getBufferSize(), 0); + FileEntryRef File = FileMgr.getVirtualFileRef(SB->getBufferIdentifier(), + SB->getBufferSize(), 0); SourceMgr.setMainFileID( SourceMgr.createFileID(File, SourceLocation(), Kind)); SourceMgr.overrideFileContents(File, std::move(SB)); Index: clang/include/clang/Basic/SourceManager.h =================================================================== --- clang/include/clang/Basic/SourceManager.h +++ clang/include/clang/Basic/SourceManager.h @@ -958,6 +958,10 @@ /// data in the given source file. void overrideFileContents(const FileEntry *SourceFile, std::unique_ptr<llvm::MemoryBuffer> Buffer); + void overrideFileContents(FileEntryRef SourceFile, + std::unique_ptr<llvm::MemoryBuffer> Buffer) { + overrideFileContents(&SourceFile.getFileEntry(), std::move(Buffer)); + } /// Override the given source file with another one. ///
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits