[PATCH] D89430: clang/Basic: Remove SourceManager::getBufferPointer, NFC

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 20 15:03:07 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG747b134d019c: clang/Basic: Remove SourceManager::getBufferPointer, NFC (authored by dexonsmith).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89430/new/

https://reviews.llvm.org/D89430

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/SourceManager.cpp


Index: clang/lib/Basic/SourceManager.cpp
===================================================================
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -121,22 +121,14 @@
 llvm::Optional<llvm::MemoryBufferRef>
 ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
                               SourceLocation Loc) const {
-  if (auto *B = getBufferPointer(Diag, FM, Loc))
-    return B->getMemBufferRef();
-  return None;
-}
-
-const llvm::MemoryBuffer *
-ContentCache::getBufferPointer(DiagnosticsEngine &Diag, FileManager &FM,
-                               SourceLocation Loc) const {
   // Lazily create the Buffer for ContentCaches that wrap files.  If we already
   // computed it, just return what we have.
   if (isBufferInvalid())
-    return nullptr;
+    return None;
   if (auto *B = Buffer.getPointer())
-    return B;
+    return B->getMemBufferRef();
   if (!ContentsEntry)
-    return nullptr;
+    return None;
 
   // Check that the file's size fits in an 'unsigned' (with room for a
   // past-the-end value). This is deeply regrettable, but various parts of
@@ -153,7 +145,7 @@
         << ContentsEntry->getName();
 
     Buffer.setInt(Buffer.getInt() | InvalidFlag);
-    return nullptr;
+    return None;
   }
 
   auto BufferOrError = FM.getBufferForFile(ContentsEntry, IsFileVolatile);
@@ -173,7 +165,7 @@
           << ContentsEntry->getName() << BufferOrError.getError().message();
 
     Buffer.setInt(Buffer.getInt() | InvalidFlag);
-    return nullptr;
+    return None;
   }
 
   Buffer.setPointer(BufferOrError->release());
@@ -189,7 +181,7 @@
         << ContentsEntry->getName();
 
     Buffer.setInt(Buffer.getInt() | InvalidFlag);
-    return nullptr;
+    return None;
   }
 
   // If the buffer is valid, check to see if it has a UTF Byte Order Mark
@@ -202,10 +194,10 @@
     Diag.Report(Loc, diag::err_unsupported_bom)
       << InvalidBOM << ContentsEntry->getName();
     Buffer.setInt(Buffer.getInt() | InvalidFlag);
-    return nullptr;
+    return None;
   }
 
-  return Buffer.getPointer();
+  return Buffer.getPointer()->getMemBufferRef();
 }
 
 unsigned LineTableInfo::getLineTableFilenameID(StringRef Name) {
Index: clang/include/clang/Basic/SourceManager.h
===================================================================
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -188,17 +188,6 @@
     getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
                     SourceLocation Loc = SourceLocation()) const;
 
-  private:
-    /// Returns pointer to memory buffer.
-    ///
-    /// TODO: SourceManager needs access to this for now, but once that's done
-    /// we should remove this API.
-    const llvm::MemoryBuffer *getBufferPointer(DiagnosticsEngine &Diag,
-                                               FileManager &FM,
-                                               SourceLocation Loc) const;
-    friend class clang::SourceManager;
-
-  public:
     /// Returns the size of the content encapsulated by this
     /// ContentCache.
     ///


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89430.299486.patch
Type: text/x-patch
Size: 3117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201020/4bfebf96/attachment.bin>


More information about the cfe-commits mailing list