summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-07-16 07:44:51 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-07-16 07:44:51 +0000
commitb39c55f4bea5c9ab259e0441cb6ce30c0b237d99 (patch)
tree012975a1bfd400209ab980f12df562e153f31281 /llvm
parentebabadf9337c2fb3b53a7d5217d600af234e2092 (diff)
downloadbcm5719-llvm-b39c55f4bea5c9ab259e0441cb6ce30c0b237d99.tar.gz
bcm5719-llvm-b39c55f4bea5c9ab259e0441cb6ce30c0b237d99.zip
Add a boring bit of boilerplate to start testing IRBuilder::CreateCondBr.
This is in anticipation of changing CreateCondBr and wanting to test those changes. llvm-svn: 160250
Diffstat (limited to 'llvm')
-rw-r--r--llvm/unittests/VMCore/IRBuilderTest.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/unittests/VMCore/IRBuilderTest.cpp b/llvm/unittests/VMCore/IRBuilderTest.cpp
index 9be3ab9555d..3eb5926d542 100644
--- a/llvm/unittests/VMCore/IRBuilderTest.cpp
+++ b/llvm/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<Module> 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));
+}
+
}
OpenPOWER on IntegriCloud