summaryrefslogtreecommitdiffstats
path: root/clang/lib
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 /clang/lib
parentb694a0d5c58ee47333bc4fb57c5e19812748bdc4 (diff)
downloadbcm5719-llvm-e0f6d886789fc491155f6c24e6f719316af74538.tar.gz
bcm5719-llvm-e0f6d886789fc491155f6c24e6f719316af74538.zip
Use std::unique_ptr to simplify this code a bit.
llvm-svn: 215926
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/SourceManager.cpp18
1 files changed, 7 insertions, 11 deletions
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