summaryrefslogtreecommitdiff
path: root/unittests/IR/WaymarkTest.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2013-01-07 15:35:46 +0000
committerChandler Carruth <chandlerc@gmail.com>2013-01-07 15:35:46 +0000
commitc779e96158cbac4c62df8e2053ab6a933eba5868 (patch)
tree0ec9e70170d75216c6f0ed5c994a0a0ba1fac2b3 /unittests/IR/WaymarkTest.cpp
parent3251e81d793a293b78f4914be6093b405c24fc2a (diff)
downloadllvm-c779e96158cbac4c62df8e2053ab6a933eba5868.tar.gz
llvm-c779e96158cbac4c62df8e2053ab6a933eba5868.tar.bz2
llvm-c779e96158cbac4c62df8e2053ab6a933eba5868.tar.xz
Rename the VMCore unittest tree to IR. Somehow was missed when doing the
library rename. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171747 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/IR/WaymarkTest.cpp')
-rw-r--r--unittests/IR/WaymarkTest.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/unittests/IR/WaymarkTest.cpp b/unittests/IR/WaymarkTest.cpp
new file mode 100644
index 0000000000..69fc4da5a6
--- /dev/null
+++ b/unittests/IR/WaymarkTest.cpp
@@ -0,0 +1,54 @@
+//===- llvm/unittest/IR/WaymarkTest.cpp - getUser() unit tests ------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// we perform white-box tests
+//
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/LLVMContext.h"
+#include "gtest/gtest.h"
+#include <algorithm>
+
+namespace llvm {
+namespace {
+
+Constant *char2constant(char c) {
+ return ConstantInt::get(Type::getInt8Ty(getGlobalContext()), c);
+}
+
+
+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);
+ ASSERT_EQ(1U + 22, A->getNumOperands());
+ const Use *U = &A->getOperandUse(0);
+ const Use *Ue = &A->getOperandUse(22);
+ for (; U != Ue; ++U)
+ {
+ EXPECT_EQ(A, U->getUser());
+ }
+}
+
+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)
+ {
+ EXPECT_EQ((User*)(Ue + 1), U->getUser());
+ }
+}
+
+} // end anonymous namespace
+} // end namespace llvm