[PATCH] D16211: [InstructionsTest] delete via unique_ptr (NFC)
Joseph Tremoulet via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 14 20:21:43 PST 2016
JosephTremoulet created this revision.
JosephTremoulet added a reviewer: dblaikie.
JosephTremoulet added a subscriber: llvm-commits.
Simplify the memory management of mock IR in test AlterInvokeBundles.
http://reviews.llvm.org/D16211
Files:
unittests/IR/InstructionsTest.cpp
Index: unittests/IR/InstructionsTest.cpp
===================================================================
--- unittests/IR/InstructionsTest.cpp
+++ unittests/IR/InstructionsTest.cpp
@@ -551,18 +551,19 @@
Type *FnTy = FunctionType::get(Int32Ty, Int32Ty, /*isVarArg=*/false);
Value *Callee = Constant::getNullValue(FnTy->getPointerTo());
Value *Args[] = {ConstantInt::get(Int32Ty, 42)};
- BasicBlock *NormalDest = BasicBlock::Create(C);
- BasicBlock *UnwindDest = BasicBlock::Create(C);
+ std::unique_ptr<BasicBlock> NormalDest(BasicBlock::Create(C));
+ std::unique_ptr<BasicBlock> UnwindDest(BasicBlock::Create(C));
OperandBundleDef OldBundle("before", UndefValue::get(Int32Ty));
- InvokeInst *Invoke(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args,
- OldBundle, "result"));
+ std::unique_ptr<InvokeInst> Invoke(InvokeInst::Create(
+ Callee, NormalDest.get(), UnwindDest.get(), Args, OldBundle, "result"));
AttrBuilder AB;
AB.addAttribute(Attribute::Cold);
Invoke->setAttributes(AttributeSet::get(C, AttributeSet::FunctionIndex, AB));
Invoke->setDebugLoc(DebugLoc(MDNode::get(C, None)));
OperandBundleDef NewBundle("after", ConstantInt::get(Int32Ty, 7));
- InvokeInst *Clone(InvokeInst::Create(Invoke, NewBundle));
+ std::unique_ptr<InvokeInst> Clone(
+ InvokeInst::Create(Invoke.get(), NewBundle));
EXPECT_EQ(Invoke->getNormalDest(), Clone->getNormalDest());
EXPECT_EQ(Invoke->getUnwindDest(), Clone->getUnwindDest());
EXPECT_EQ(Invoke->getNumArgOperands(), Clone->getNumArgOperands());
@@ -572,11 +573,6 @@
EXPECT_EQ(Invoke->getDebugLoc(), Clone->getDebugLoc());
EXPECT_EQ(Clone->getNumOperandBundles(), 1U);
EXPECT_TRUE(Clone->getOperandBundle("after").hasValue());
-
- delete Invoke;
- delete Clone;
- delete NormalDest;
- delete UnwindDest;
}
} // end anonymous namespace
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16211.44962.patch
Type: text/x-patch
Size: 1899 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160115/67ba1e69/attachment.bin>
More information about the llvm-commits
mailing list