r216347 - Frontend: unique_ptr-ify
Dylan Noblesmith
nobled at dreamwidth.org
Sun Aug 24 11:59:54 PDT 2014
Author: nobled
Date: Sun Aug 24 13:59:52 2014
New Revision: 216347
URL: http://llvm.org/viewvc/llvm-project?rev=216347&view=rev
Log:
Frontend: unique_ptr-ify
NFC.
Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=216347&r1=216346&r2=216347&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Sun Aug 24 13:59:52 2014
@@ -105,7 +105,8 @@ static llvm::sys::SmartMutex<false> &get
static void cleanupOnDiskMapAtExit();
-typedef llvm::DenseMap<const ASTUnit *, OnDiskData *> OnDiskDataMap;
+typedef llvm::DenseMap<const ASTUnit *,
+ std::unique_ptr<OnDiskData>> OnDiskDataMap;
static OnDiskDataMap &getOnDiskDataMap() {
static OnDiskDataMap M;
static bool hasRegisteredAtExit = false;
@@ -132,9 +133,9 @@ static OnDiskData &getOnDiskData(const A
// DenseMap.
llvm::MutexGuard Guard(getOnDiskMutex());
OnDiskDataMap &M = getOnDiskDataMap();
- OnDiskData *&D = M[AU];
+ auto &D = M[AU];
if (!D)
- D = new OnDiskData();
+ D = llvm::make_unique<OnDiskData>();
return *D;
}
@@ -150,7 +151,6 @@ static void removeOnDiskEntry(const ASTU
OnDiskDataMap::iterator I = M.find(AU);
if (I != M.end()) {
I->second->Cleanup();
- delete I->second;
M.erase(AU);
}
}
More information about the cfe-commits
mailing list