From 4b31c4d93ff23c4b9a5d9169ff5e6f51731fca17 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 16 Jul 2012 07:44:51 +0000 Subject: Add a boring bit of boilerplate to start testing IRBuilder::CreateCondBr. This is in anticipation of changing CreateCondBr and wanting to test those changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160250 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/VMCore/IRBuilderTest.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'unittests') diff --git a/unittests/VMCore/IRBuilderTest.cpp b/unittests/VMCore/IRBuilderTest.cpp index 9be3ab9555..3eb5926d54 100644 --- a/unittests/VMCore/IRBuilderTest.cpp +++ b/unittests/VMCore/IRBuilderTest.cpp @@ -27,7 +27,7 @@ protected: M.reset(new Module("MyModule", getGlobalContext())); FunctionType *FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), /*isVarArg=*/false); - Function *F = Function::Create(FTy, Function::ExternalLinkage, "", M.get()); + F = Function::Create(FTy, Function::ExternalLinkage, "", M.get()); BB = BasicBlock::Create(getGlobalContext(), "", F); } @@ -37,6 +37,7 @@ protected: } OwningPtr M; + Function *F; BasicBlock *BB; }; @@ -71,4 +72,17 @@ TEST_F(IRBuilderTest, Lifetime) { EXPECT_EQ(II_End1->getIntrinsicID(), Intrinsic::lifetime_end); } +TEST_F(IRBuilderTest, CreateCondBr) { + IRBuilder<> Builder(BB); + BasicBlock *TBB = BasicBlock::Create(getGlobalContext(), "", F); + BasicBlock *FBB = BasicBlock::Create(getGlobalContext(), "", F); + + BranchInst *BI = Builder.CreateCondBr(Builder.getTrue(), TBB, FBB); + TerminatorInst *TI = BB->getTerminator(); + EXPECT_EQ(BI, TI); + EXPECT_EQ(2u, TI->getNumSuccessors()); + EXPECT_EQ(TBB, TI->getSuccessor(0)); + EXPECT_EQ(FBB, TI->getSuccessor(1)); +} + } -- cgit v1.2.3