diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-10-14 22:34:19 -0400 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-10-22 14:00:44 -0400 |
commit | 156e8b37024abd8630666e0ae8a251b80299ed1d (patch) | |
tree | 4e998566e37e0d9e56ef0ffb891fc2fb4b12075d /clang/lib/Basic/SourceManager.cpp | |
parent | b9eecbfada4f4e7e8b74434b4fc538d325d95cfc (diff) | |
download | llvm-156e8b37024abd8630666e0ae8a251b80299ed1d.zip llvm-156e8b37024abd8630666e0ae8a251b80299ed1d.tar.gz llvm-156e8b37024abd8630666e0ae8a251b80299ed1d.tar.bz2 |
clang/Basic: Remove ContentCache::getRawBuffer, NFC
Replace `ContentCache::getRawBuffer` with `getBufferDataIfLoaded` and
`getBufferIfLoaded`, excising another accessor for the underlying
`MemoryBuffer*` in favour of `StringRef` and `MemoryBufferRef`.
Differential Revision: https://reviews.llvm.org/D89445
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index f61b4e2..9592b92 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -155,7 +155,7 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, // Check that the file's size is the same as in the file entry (which may // have come from a stat cache). - if (getRawBuffer()->getBufferSize() != (size_t)ContentsEntry->getSize()) { + if (Buffer->getBufferSize() != (size_t)ContentsEntry->getSize()) { if (Diag.isDiagnosticInFlight()) Diag.SetDelayedDiagnostic(diag::err_file_modified, ContentsEntry->getName()); @@ -363,7 +363,7 @@ void SourceManager::initializeForReplay(const SourceManager &Old) { Clone->BufferOverridden = Cache->BufferOverridden; Clone->IsFileVolatile = Cache->IsFileVolatile; Clone->IsTransient = Cache->IsTransient; - Clone->setUnownedBuffer(Cache->getRawBuffer()); + Clone->setUnownedBuffer(Cache->getBufferIfLoaded()); return Clone; }; @@ -476,7 +476,8 @@ const SrcMgr::ContentCache * SourceManager::getFakeContentCacheForRecovery() const { if (!FakeContentCacheForRecovery) { FakeContentCacheForRecovery = std::make_unique<SrcMgr::ContentCache>(); - FakeContentCacheForRecovery->setUnownedBuffer(getFakeBufferForRecovery()); + FakeContentCacheForRecovery->setUnownedBuffer( + getFakeBufferForRecovery()->getMemBufferRef()); } return FakeContentCacheForRecovery.get(); } @@ -751,10 +752,7 @@ SourceManager::getBufferDataIfLoaded(FileID FID) const { if (!SLoc.isFile() || MyInvalid) return None; - if (const llvm::MemoryBuffer *Buf = - SLoc.getFile().getContentCache()->getRawBuffer()) - return Buf->getBuffer(); - return None; + return SLoc.getFile().getContentCache()->getBufferDataIfLoaded(); } llvm::Optional<StringRef> SourceManager::getBufferDataOrNone(FileID FID) const { |