diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2023-09-13 11:45:29 -0700 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2023-09-29 09:30:21 -0700 |
commit | 2da8f30c5e9a26cd3ca7f5aa8489eb0f0f3c8559 (patch) | |
tree | 9f6020b8e72e161ead2d021b85927d922db1e6e8 /clang/lib/Frontend/CompilerInstance.cpp | |
parent | 1610311a95b1a98f47e9242d67141c5b3e44a138 (diff) | |
download | llvm-2da8f30c5e9a26cd3ca7f5aa8489eb0f0f3c8559.zip llvm-2da8f30c5e9a26cd3ca7f5aa8489eb0f0f3c8559.tar.gz llvm-2da8f30c5e9a26cd3ca7f5aa8489eb0f0f3c8559.tar.bz2 |
[clang] NFCI: Use `FileEntryRef` in `SourceManager::overrideFileContents()`
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index aacbb20..d18371f 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -400,14 +400,8 @@ static void InitializeFileRemapping(DiagnosticsEngine &Diags, // Remap files in the source manager (with buffers). for (const auto &RB : InitOpts.RemappedFileBuffers) { // Create the file entry for the file that we're mapping from. - const FileEntry *FromFile = - FileMgr.getVirtualFile(RB.first, RB.second->getBufferSize(), 0); - if (!FromFile) { - Diags.Report(diag::err_fe_remap_missing_from_file) << RB.first; - if (!InitOpts.RetainRemappedFileBuffers) - delete RB.second; - continue; - } + FileEntryRef FromFile = + FileMgr.getVirtualFileRef(RB.first, RB.second->getBufferSize(), 0); // Override the contents of the "from" file with the contents of the // "to" file. If the caller owns the buffers, then pass a MemoryBufferRef; @@ -701,7 +695,7 @@ static bool EnableCodeCompletion(Preprocessor &PP, unsigned Column) { // Tell the source manager to chop off the given file at a specific // line and column. - auto Entry = PP.getFileManager().getFile(Filename); + auto Entry = PP.getFileManager().getOptionalFileRef(Filename); if (!Entry) { PP.getDiagnostics().Report(diag::err_fe_invalid_code_complete_file) << Filename; @@ -1357,7 +1351,7 @@ static bool compileModule(CompilerInstance &ImportingInstance, [&](CompilerInstance &Instance) { std::unique_ptr<llvm::MemoryBuffer> ModuleMapBuffer = llvm::MemoryBuffer::getMemBuffer(InferredModuleMapContent); - const FileEntry *ModuleMapFile = Instance.getFileManager().getVirtualFile( + FileEntryRef ModuleMapFile = Instance.getFileManager().getVirtualFileRef( FakeModuleMapFile, InferredModuleMapContent.size(), 0); Instance.getSourceManager().overrideFileContents( ModuleMapFile, std::move(ModuleMapBuffer)); @@ -2182,7 +2176,7 @@ void CompilerInstance::createModuleFromSource(SourceLocation ImportLoc, auto PreBuildStep = [&](CompilerInstance &Other) { // Create a virtual file containing our desired source. // FIXME: We shouldn't need to do this. - const FileEntry *ModuleMapFile = Other.getFileManager().getVirtualFile( + FileEntryRef ModuleMapFile = Other.getFileManager().getVirtualFileRef( ModuleMapFileName, NullTerminatedSource.size(), 0); Other.getSourceManager().overrideFileContents( ModuleMapFile, llvm::MemoryBuffer::getMemBuffer(NullTerminatedSource)); |