diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-10-14 18:17:01 -0400 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-10-20 18:02:42 -0400 |
commit | 747b134d019ce99bc4463d09992634965ee95031 (patch) | |
tree | 64623d79550c7806b28b3d4a340108f4481ff7c3 /clang/lib/Basic/SourceManager.cpp | |
parent | 96f372c1e7402595edd2ae9f86b9bdfa22dc1045 (diff) | |
download | llvm-747b134d019ce99bc4463d09992634965ee95031.zip llvm-747b134d019ce99bc4463d09992634965ee95031.tar.gz llvm-747b134d019ce99bc4463d09992634965ee95031.tar.bz2 |
clang/Basic: Remove SourceManager::getBufferPointer, NFC
Inline `Source::getBufferPointer` into its only remaining caller,
`getBufferOrNone`. No functionality change.
Differential Revision: https://reviews.llvm.org/D89430
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 51772d5..27d2f39 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -121,22 +121,14 @@ const char *ContentCache::getInvalidBOM(StringRef BufStr) { 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 @@ ContentCache::getBufferPointer(DiagnosticsEngine &Diag, FileManager &FM, << ContentsEntry->getName(); Buffer.setInt(Buffer.getInt() | InvalidFlag); - return nullptr; + return None; } auto BufferOrError = FM.getBufferForFile(ContentsEntry, IsFileVolatile); @@ -173,7 +165,7 @@ ContentCache::getBufferPointer(DiagnosticsEngine &Diag, FileManager &FM, << ContentsEntry->getName() << BufferOrError.getError().message(); Buffer.setInt(Buffer.getInt() | InvalidFlag); - return nullptr; + return None; } Buffer.setPointer(BufferOrError->release()); @@ -189,7 +181,7 @@ ContentCache::getBufferPointer(DiagnosticsEngine &Diag, FileManager &FM, << 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 @@ ContentCache::getBufferPointer(DiagnosticsEngine &Diag, FileManager &FM, 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) { |