summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-08-18 18:33:41 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-08-18 18:33:41 +0000
commite0f6d886789fc491155f6c24e6f719316af74538 (patch)
treece39f315ae99e80c45e308e32294973460519958
parentb694a0d5c58ee47333bc4fb57c5e19812748bdc4 (diff)
downloadbcm5719-llvm-e0f6d886789fc491155f6c24e6f719316af74538.tar.gz
bcm5719-llvm-e0f6d886789fc491155f6c24e6f719316af74538.zip
Use std::unique_ptr to simplify this code a bit.
llvm-svn: 215926
-rw-r--r--clang/include/clang/Basic/SourceManager.h4
-rw-r--r--clang/lib/Basic/SourceManager.cpp18
2 files changed, 9 insertions, 13 deletions
diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h
index 484765b41c5..03b301d5ca4 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -685,9 +685,9 @@ class SourceManager : public RefCountedBase<SourceManager> {
InBeforeInTUCacheEntry &getInBeforeInTUCache(FileID LFID, FileID RFID) const;
// Cache for the "fake" buffer used for error-recovery purposes.
- mutable llvm::MemoryBuffer *FakeBufferForRecovery;
+ mutable std::unique_ptr<llvm::MemoryBuffer> FakeBufferForRecovery;
- mutable SrcMgr::ContentCache *FakeContentCacheForRecovery;
+ mutable std::unique_ptr<SrcMgr::ContentCache> FakeContentCacheForRecovery;
/// \brief Lazily computed map of macro argument chunks to their expanded
/// source location.
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 61dfe35e225..14de7607c3b 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -373,8 +373,7 @@ SourceManager::SourceManager(DiagnosticsEngine &Diag, FileManager &FileMgr,
: Diag(Diag), FileMgr(FileMgr), OverridenFilesKeepOriginalName(true),
UserFilesAreVolatile(UserFilesAreVolatile),
ExternalSLocEntries(nullptr), LineTable(nullptr), NumLinearScans(0),
- NumBinaryProbes(0), FakeBufferForRecovery(nullptr),
- FakeContentCacheForRecovery(nullptr) {
+ NumBinaryProbes(0) {
clearIDTables();
Diag.setSourceManager(this);
}
@@ -398,9 +397,6 @@ SourceManager::~SourceManager() {
ContentCacheAlloc.Deallocate(I->second);
}
}
-
- delete FakeBufferForRecovery;
- delete FakeContentCacheForRecovery;
llvm::DeleteContainerSeconds(MacroArgsCacheMap);
}
@@ -505,10 +501,10 @@ SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries,
/// fake, non-empty buffer.
llvm::MemoryBuffer *SourceManager::getFakeBufferForRecovery() const {
if (!FakeBufferForRecovery)
- FakeBufferForRecovery
- = llvm::MemoryBuffer::getMemBuffer("<<<INVALID BUFFER>>");
-
- return FakeBufferForRecovery;
+ FakeBufferForRecovery.reset(
+ llvm::MemoryBuffer::getMemBuffer("<<<INVALID BUFFER>>"));
+
+ return FakeBufferForRecovery.get();
}
/// \brief As part of recovering from missing or changed content, produce a
@@ -516,11 +512,11 @@ llvm::MemoryBuffer *SourceManager::getFakeBufferForRecovery() const {
const SrcMgr::ContentCache *
SourceManager::getFakeContentCacheForRecovery() const {
if (!FakeContentCacheForRecovery) {
- FakeContentCacheForRecovery = new ContentCache();
+ FakeContentCacheForRecovery = llvm::make_unique<SrcMgr::ContentCache>();
FakeContentCacheForRecovery->replaceBuffer(getFakeBufferForRecovery(),
/*DoNotFree=*/true);
}
- return FakeContentCacheForRecovery;
+ return FakeContentCacheForRecovery.get();
}
/// \brief Returns the previous in-order FileID or an invalid FileID if there
OpenPOWER on IntegriCloud