[llvm-branch-commits] [clang] a5c89bb - Frontend: Migrate to FileEntryRef in CompilerInstance::InitializeSourceManager, NFC
Duncan P. N. Exon Smith via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 9 13:32:55 PST 2020
Author: Duncan P. N. Exon Smith
Date: 2020-12-09T13:28:29-08:00
New Revision: a5c89bb02195a97aa71a4033336d9864098c764f
URL: https://github.com/llvm/llvm-project/commit/a5c89bb02195a97aa71a4033336d9864098c764f
DIFF: https://github.com/llvm/llvm-project/commit/a5c89bb02195a97aa71a4033336d9864098c764f.diff
LOG: Frontend: Migrate to FileEntryRef in CompilerInstance::InitializeSourceManager, NFC
Use `FileManager::getVirtualFileRef` to get the virtual file for stdin,
and add an overload of `SourceManager::overrideFileContents` that takes
a `FileEntryRef`, migrating `CompilerInstance::InitializeSourceManager`.
Differential Revision: https://reviews.llvm.org/D92680
Added:
Modified:
clang/include/clang/Basic/SourceManager.h
clang/lib/Frontend/CompilerInstance.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h
index 05edc98f9ec8..e067cd8fad83 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -958,6 +958,10 @@ class SourceManager : public RefCountedBase<SourceManager> {
/// 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.
///
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index fa3d50aeedfe..92e5208b193b 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -891,8 +891,8 @@ bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input,
}
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));
More information about the llvm-branch-commits
mailing list