[llvm] r206785 - Use unique_ptr to handle ownership of UserValues in LiveDebugVariablesImpl
David Blaikie
dblaikie at gmail.com
Mon Apr 21 13:37:07 PDT 2014
Author: dblaikie
Date: Mon Apr 21 15:37:07 2014
New Revision: 206785
URL: http://llvm.org/viewvc/llvm-project?rev=206785&view=rev
Log:
Use unique_ptr to handle ownership of UserValues in LiveDebugVariablesImpl
Modified:
llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp
Modified: llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp?rev=206785&r1=206784&r2=206785&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp Mon Apr 21 15:37:07 2014
@@ -41,6 +41,8 @@
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegisterInfo.h"
+#include <memory>
+
using namespace llvm;
static cl::opt<bool>
@@ -292,7 +294,7 @@ class LDVImpl {
bool ModifiedMF;
/// userValues - All allocated UserValue instances.
- SmallVector<UserValue*, 8> userValues;
+ SmallVector<std::unique_ptr<UserValue>, 8> userValues;
/// Map virtual register to eq class leader.
typedef DenseMap<unsigned, UserValue*> VRMap;
@@ -332,7 +334,6 @@ public:
/// clear - Release all memory.
void clear() {
- DeleteContainerPointers(userValues);
userValues.clear();
virtRegToEqClass.clear();
userVarMap.clear();
@@ -429,8 +430,9 @@ UserValue *LDVImpl::getUserValue(const M
return UV;
}
- UserValue *UV = new UserValue(Var, Offset, IsIndirect, DL, allocator);
- userValues.push_back(UV);
+ userValues.push_back(
+ make_unique<UserValue>(Var, Offset, IsIndirect, DL, allocator));
+ UserValue *UV = userValues.back().get();
Leader = UserValue::merge(Leader, UV);
return UV;
}
More information about the llvm-commits
mailing list