Author: Jan Svoboda
Date: 2023-09-29T10:31:42-07:00
New Revision: 3661a48a84731ab5086bf1fca8f7e6b9f294225a

URL: 
https://github.com/llvm/llvm-project/commit/3661a48a84731ab5086bf1fca8f7e6b9f294225a
DIFF: 
https://github.com/llvm/llvm-project/commit/3661a48a84731ab5086bf1fca8f7e6b9f294225a.diff

LOG: [clang] NFCI: Use `FileEntryRef` in 
`SourceManager::getMemoryBufferForFileOr{None,Fake}()`

Added: 
    

Modified: 
    clang/include/clang/Basic/SourceManager.h
    clang/lib/Basic/SourceManager.cpp
    clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index b882efcd8c57cdc..4abb9a19622871b 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -942,12 +942,12 @@ class SourceManager : public 
RefCountedBase<SourceManager> {
   ///
   /// Returns std::nullopt if the buffer is not valid.
   std::optional<llvm::MemoryBufferRef>
-  getMemoryBufferForFileOrNone(const FileEntry *File);
+  getMemoryBufferForFileOrNone(FileEntryRef File);
 
   /// Retrieve the memory buffer associated with the given file.
   ///
   /// Returns a fake buffer if there isn't a real one.
-  llvm::MemoryBufferRef getMemoryBufferForFileOrFake(const FileEntry *File) {
+  llvm::MemoryBufferRef getMemoryBufferForFileOrFake(FileEntryRef File) {
     if (auto B = getMemoryBufferForFileOrNone(File))
       return *B;
     return getFakeBufferForRecovery();

diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 3ca5dccb40e4f1e..f1a81de329319a0 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -681,8 +681,8 @@ SourceManager::createExpansionLocImpl(const ExpansionInfo 
&Info,
 }
 
 std::optional<llvm::MemoryBufferRef>
-SourceManager::getMemoryBufferForFileOrNone(const FileEntry *File) {
-  SrcMgr::ContentCache &IR = getOrCreateContentCache(File->getLastRef());
+SourceManager::getMemoryBufferForFileOrNone(FileEntryRef File) {
+  SrcMgr::ContentCache &IR = getOrCreateContentCache(File);
   return IR.getBufferOrNone(Diag, getFileManager(), SourceLocation());
 }
 

diff  --git a/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp 
b/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
index 036a995e4a2ec17..0b3c4de08ab8593 100644
--- a/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
+++ b/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
@@ -57,7 +57,7 @@ bool isImportLine(llvm::StringRef Line) {
   return Line.startswith("import");
 }
 
-llvm::StringRef getFileContents(const FileEntry *FE, const SourceManager &SM) {
+llvm::StringRef getFileContents(FileEntryRef FE, const SourceManager &SM) {
   return const_cast<SourceManager &>(SM)
       .getMemoryBufferForFileOrNone(FE)
       .value_or(llvm::MemoryBufferRef())


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to