Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 864c531

Browse files
committed
Use unique_ptr to handle ownership of UserValues in LiveDebugVariablesImpl
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206785 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 52d629e commit 864c531

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/CodeGen/LiveDebugVariables.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#include "llvm/Target/TargetMachine.h"
4242
#include "llvm/Target/TargetRegisterInfo.h"
4343

44+
#include <memory>
45+
4446
using namespace llvm;
4547

4648
static cl::opt<bool>
@@ -292,7 +294,7 @@ class LDVImpl {
292294
bool ModifiedMF;
293295

294296
/// userValues - All allocated UserValue instances.
295-
SmallVector<UserValue*, 8> userValues;
297+
SmallVector<std::unique_ptr<UserValue>, 8> userValues;
296298

297299
/// Map virtual register to eq class leader.
298300
typedef DenseMap<unsigned, UserValue*> VRMap;
@@ -332,7 +334,6 @@ class LDVImpl {
332334

333335
/// clear - Release all memory.
334336
void clear() {
335-
DeleteContainerPointers(userValues);
336337
userValues.clear();
337338
virtRegToEqClass.clear();
338339
userVarMap.clear();
@@ -429,8 +430,9 @@ UserValue *LDVImpl::getUserValue(const MDNode *Var, unsigned Offset,
429430
return UV;
430431
}
431432

432-
UserValue *UV = new UserValue(Var, Offset, IsIndirect, DL, allocator);
433-
userValues.push_back(UV);
433+
userValues.push_back(
434+
make_unique<UserValue>(Var, Offset, IsIndirect, DL, allocator));
435+
UserValue *UV = userValues.back().get();
434436
Leader = UserValue::merge(Leader, UV);
435437
return UV;
436438
}

0 commit comments

Comments
 (0)