[llvm] r257892 - [InstructionsTest] delete via unique_ptr (NFC)
Joseph Tremoulet via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 15 07:08:36 PST 2016
Author: josepht
Date: Fri Jan 15 09:08:36 2016
New Revision: 257892
URL: http://llvm.org/viewvc/llvm-project?rev=257892&view=rev
Log:
[InstructionsTest] delete via unique_ptr (NFC)
Summary:
Simplify the memory management of mock IR in test AlterInvokeBundles.
Reviewers: dblaikie
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D16211
Modified:
llvm/trunk/unittests/IR/InstructionsTest.cpp
Modified: llvm/trunk/unittests/IR/InstructionsTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/InstructionsTest.cpp?rev=257892&r1=257891&r2=257892&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/InstructionsTest.cpp (original)
+++ llvm/trunk/unittests/IR/InstructionsTest.cpp Fri Jan 15 09:08:36 2016
@@ -551,18 +551,19 @@ TEST(InstructionsTest, AlterInvokeBundle
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 @@ TEST(InstructionsTest, AlterInvokeBundle
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
More information about the llvm-commits
mailing list