[clang] 3e9c363 - [clang] NFCI: Use `FileEntryRef` in `SourceManager::setFileIsTransient()`

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 28 14:59:03 PDT 2023


Author: Jan Svoboda
Date: 2023-09-28T14:50:00-07:00
New Revision: 3e9c36303ca72929275fb97767af43b3aa04cab1

URL: https://github.com/llvm/llvm-project/commit/3e9c36303ca72929275fb97767af43b3aa04cab1
DIFF: https://github.com/llvm/llvm-project/commit/3e9c36303ca72929275fb97767af43b3aa04cab1.diff

LOG: [clang] NFCI: Use `FileEntryRef` in `SourceManager::setFileIsTransient()`

Added: 
    

Modified: 
    clang/include/clang/Basic/SourceManager.h
    clang/lib/Basic/SourceManager.cpp
    clang/lib/Frontend/FrontendAction.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..431f97f30525b04 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -1006,7 +1006,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
   OptionalFileEntryRef bypassFileContentsOverride(FileEntryRef File);
 
   /// Specify that a file is transient.
-  void setFileIsTransient(const FileEntry *SourceFile);
+  void setFileIsTransient(FileEntryRef SourceFile);
 
   /// Specify that all files that are read during this compilation are
   /// transient.

diff  --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 757b7ea68bb14a4..a630743e0d73e13 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -725,8 +725,8 @@ SourceManager::bypassFileContentsOverride(FileEntryRef File) {
   return BypassFile;
 }
 
-void SourceManager::setFileIsTransient(const FileEntry *File) {
-  getOrCreateContentCache(File->getLastRef()).IsTransient = true;
+void SourceManager::setFileIsTransient(FileEntryRef File) {
+  getOrCreateContentCache(File).IsTransient = true;
 }
 
 std::optional<StringRef>

diff  --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index ada86b0a015661d..2da1a89b39ba4ba 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -742,7 +742,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
   // Set up embedding for any specified files. Do this before we load any
   // source files, including the primary module map for the compilation.
   for (const auto &F : CI.getFrontendOpts().ModulesEmbedFiles) {
-    if (auto FE = CI.getFileManager().getFile(F, /*openFile*/true))
+    if (auto FE = CI.getFileManager().getOptionalFileRef(F, /*openFile*/true))
       CI.getSourceManager().setFileIsTransient(*FE);
     else
       CI.getDiagnostics().Report(diag::err_modules_embed_file_not_found) << F;


        


More information about the cfe-commits mailing list