1 //===- llvm/unittest/VMCore/WaymarkTest.cpp - getUser() unit tests --------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // we perform white-box tests
12 #include "llvm/Function.h"
13 #include "llvm/Instructions.h"
14 #include "llvm/LLVMContext.h"
15 #include "gtest/gtest.h"
21 Constant *char2constant(char c) {
22 return ConstantInt::get(Type::getInt8Ty(getGlobalContext()), c);
26 TEST(WaymarkTest, NativeArray) {
27 static uint8_t tail[22] = "s02s33s30y2y0s1x0syxS";
29 std::transform(tail, tail + 22, values, char2constant);
30 FunctionType *FT = FunctionType::get(Type::getVoidTy(getGlobalContext()), true);
31 Function *F = Function::Create(FT, GlobalValue::ExternalLinkage);
32 const CallInst *A = CallInst::Create(F, makeArrayRef(values));
33 ASSERT_NE(A, (const CallInst*)NULL);
34 ASSERT_EQ(1U + 22, A->getNumOperands());
35 const Use *U = &A->getOperandUse(0);
36 const Use *Ue = &A->getOperandUse(22);
39 EXPECT_EQ(A, U->getUser());
43 TEST(WaymarkTest, TwoBit) {
44 Use* many = (Use*)calloc(sizeof(Use), 8212 + 1);
46 Use::initTags(many, many + 8212);
47 for (const Use *U = many, *Ue = many + 8212 - 1; U != Ue; ++U)
49 EXPECT_EQ((User*)(Ue + 1), U->getUser());
53 } // end anonymous namespace
54 } // end namespace llvm