X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=unittests%2FIR%2FWaymarkTest.cpp;h=a8924efed3f5fc72e0595deab247fc6d4359c5a6;hb=00552e3875ee5f382db6c98286a241a7d0efe1b8;hp=1e9807554ccceeb4a8aed2847086361f205cd491;hpb=c8be88ab562412da359f714502e30ff61459efa0;p=oota-llvm.git diff --git a/unittests/IR/WaymarkTest.cpp b/unittests/IR/WaymarkTest.cpp index 1e9807554cc..a8924efed3f 100644 --- a/unittests/IR/WaymarkTest.cpp +++ b/unittests/IR/WaymarkTest.cpp @@ -9,6 +9,7 @@ // we perform white-box tests // +#include "llvm/IR/Constants.h" #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/LLVMContext.h" @@ -27,28 +28,30 @@ TEST(WaymarkTest, NativeArray) { static uint8_t tail[22] = "s02s33s30y2y0s1x0syxS"; Value * values[22]; std::transform(tail, tail + 22, values, char2constant); - FunctionType *FT = FunctionType::get(Type::getVoidTy(getGlobalContext()), true); - Function *F = Function::Create(FT, GlobalValue::ExternalLinkage); - const CallInst *A = CallInst::Create(F, makeArrayRef(values)); - ASSERT_NE(A, (const CallInst*)NULL); + FunctionType *FT = FunctionType::get(Type::getVoidTy(getGlobalContext()), true); + std::unique_ptr F( + Function::Create(FT, GlobalValue::ExternalLinkage)); + const CallInst *A = CallInst::Create(F.get(), makeArrayRef(values)); + ASSERT_NE(A, (const CallInst*)nullptr); ASSERT_EQ(1U + 22, A->getNumOperands()); - const Use *U = &A->getOperandUse(0); - const Use *Ue = &A->getOperandUse(22); + const Use *U = &A->getOperandUse(0); + const Use *Ue = &A->getOperandUse(22); for (; U != Ue; ++U) { EXPECT_EQ(A, U->getUser()); } + delete A; } TEST(WaymarkTest, TwoBit) { Use* many = (Use*)calloc(sizeof(Use), 8212 + 1); ASSERT_TRUE(many); - Use::initTags(many, many + 8212); - for (const Use *U = many, *Ue = many + 8212 - 1; U != Ue; ++U) + Use::initTags(many, many + 8212); + for (Use *U = many, *Ue = many + 8212 - 1; U != Ue; ++U) { - EXPECT_EQ(reinterpret_cast(const_cast(Ue + 1)), - U->getUser()); + EXPECT_EQ(reinterpret_cast(Ue + 1), U->getUser()); } + free(many); } } // end anonymous namespace