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. /// Index: clang/lib/Basic/SourceManager.cpp =================================================================== --- clang/lib/Basic/SourceManager.cpp +++ clang/lib/Basic/SourceManager.cpp @@ -121,22 +121,14 @@ llvm::Optional 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) {