[llvm-commits] [llvm] r75262 - in /llvm/trunk: include/llvm/Support/TypeBuilder.h unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp unittests/Support/TypeBuilderTest.cpp
Owen Anderson
resistor at mac.com
Fri Jul 10 11:58:56 PDT 2009
Author: resistor
Date: Fri Jul 10 13:58:29 2009
New Revision: 75262
URL: http://llvm.org/viewvc/llvm-project?rev=75262&view=rev
Log:
Fix unit tests.
Modified:
llvm/trunk/include/llvm/Support/TypeBuilder.h
llvm/trunk/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp
llvm/trunk/unittests/Support/TypeBuilderTest.cpp
Modified: llvm/trunk/include/llvm/Support/TypeBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TypeBuilder.h?rev=75262&r1=75261&r2=75262&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/TypeBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/TypeBuilder.h Fri Jul 10 13:58:29 2009
@@ -16,6 +16,7 @@
#define LLVM_SUPPORT_TYPEBUILDER_H
#include "llvm/DerivedTypes.h"
+#include "llvm/LLVMContext.h"
#include <limits.h>
namespace llvm {
@@ -234,7 +235,7 @@
template<bool cross> class TypeBuilder<void, cross> {
public:
- static const Type *get(LLVMContxt&) {
+ static const Type *get(LLVMContext&) {
return Type::VoidTy;
}
};
Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp?rev=75262&r1=75261&r2=75262&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp Fri Jul 10 13:58:29 2009
@@ -65,7 +65,7 @@
class JITEventListenerTest : public testing::Test {
protected:
JITEventListenerTest()
- : M(new Module("module", *new LLVMContext())),
+ : M(new Module("module", getGlobalContext())),
EE(ExecutionEngine::createJIT(new ExistingModuleProvider(M))) {
}
@@ -75,7 +75,7 @@
Function *buildFunction(Module *M) {
Function *Result = Function::Create(
- TypeBuilder<int32_t(int32_t), false>::get(),
+ TypeBuilder<int32_t(int32_t), false>::get(getGlobalContext()),
GlobalValue::ExternalLinkage, "id", M);
Value *Arg = Result->arg_begin();
BasicBlock *BB = BasicBlock::Create("entry", Result);
Modified: llvm/trunk/unittests/Support/TypeBuilderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TypeBuilderTest.cpp?rev=75262&r1=75261&r2=75262&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/TypeBuilderTest.cpp (original)
+++ llvm/trunk/unittests/Support/TypeBuilderTest.cpp Fri Jul 10 13:58:29 2009
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/TypeBuilder.h"
+#include "llvm/LLVMContext.h"
#include "gtest/gtest.h"
@@ -16,134 +17,134 @@
namespace {
TEST(TypeBuilderTest, Void) {
- EXPECT_EQ(Type::VoidTy, (TypeBuilder<void, true>::get()));
- EXPECT_EQ(Type::VoidTy, (TypeBuilder<void, false>::get()));
+ EXPECT_EQ(Type::VoidTy, (TypeBuilder<void, true>::get(getGlobalContext())));
+ EXPECT_EQ(Type::VoidTy, (TypeBuilder<void, false>::get(getGlobalContext())));
// Special case for C compatibility:
EXPECT_EQ(PointerType::getUnqual(Type::Int8Ty),
- (TypeBuilder<void*, false>::get()));
+ (TypeBuilder<void*, false>::get(getGlobalContext())));
}
TEST(TypeBuilderTest, HostIntegers) {
- EXPECT_EQ(Type::Int8Ty, (TypeBuilder<int8_t, false>::get()));
- EXPECT_EQ(Type::Int8Ty, (TypeBuilder<uint8_t, false>::get()));
- EXPECT_EQ(Type::Int16Ty, (TypeBuilder<int16_t, false>::get()));
- EXPECT_EQ(Type::Int16Ty, (TypeBuilder<uint16_t, false>::get()));
- EXPECT_EQ(Type::Int32Ty, (TypeBuilder<int32_t, false>::get()));
- EXPECT_EQ(Type::Int32Ty, (TypeBuilder<uint32_t, false>::get()));
- EXPECT_EQ(Type::Int64Ty, (TypeBuilder<int64_t, false>::get()));
- EXPECT_EQ(Type::Int64Ty, (TypeBuilder<uint64_t, false>::get()));
+ EXPECT_EQ(Type::Int8Ty, (TypeBuilder<int8_t, false>::get(getGlobalContext())));
+ EXPECT_EQ(Type::Int8Ty, (TypeBuilder<uint8_t, false>::get(getGlobalContext())));
+ EXPECT_EQ(Type::Int16Ty, (TypeBuilder<int16_t, false>::get(getGlobalContext())));
+ EXPECT_EQ(Type::Int16Ty, (TypeBuilder<uint16_t, false>::get(getGlobalContext())));
+ EXPECT_EQ(Type::Int32Ty, (TypeBuilder<int32_t, false>::get(getGlobalContext())));
+ EXPECT_EQ(Type::Int32Ty, (TypeBuilder<uint32_t, false>::get(getGlobalContext())));
+ EXPECT_EQ(Type::Int64Ty, (TypeBuilder<int64_t, false>::get(getGlobalContext())));
+ EXPECT_EQ(Type::Int64Ty, (TypeBuilder<uint64_t, false>::get(getGlobalContext())));
EXPECT_EQ(IntegerType::get(sizeof(size_t) * CHAR_BIT),
- (TypeBuilder<size_t, false>::get()));
+ (TypeBuilder<size_t, false>::get(getGlobalContext())));
EXPECT_EQ(IntegerType::get(sizeof(ptrdiff_t) * CHAR_BIT),
- (TypeBuilder<ptrdiff_t, false>::get()));
+ (TypeBuilder<ptrdiff_t, false>::get(getGlobalContext())));
}
TEST(TypeBuilderTest, CrossCompilableIntegers) {
- EXPECT_EQ(IntegerType::get(1), (TypeBuilder<types::i<1>, true>::get()));
- EXPECT_EQ(IntegerType::get(1), (TypeBuilder<types::i<1>, false>::get()));
- EXPECT_EQ(IntegerType::get(72), (TypeBuilder<types::i<72>, true>::get()));
- EXPECT_EQ(IntegerType::get(72), (TypeBuilder<types::i<72>, false>::get()));
+ EXPECT_EQ(IntegerType::get(1), (TypeBuilder<types::i<1>, true>::get(getGlobalContext())));
+ EXPECT_EQ(IntegerType::get(1), (TypeBuilder<types::i<1>, false>::get(getGlobalContext())));
+ EXPECT_EQ(IntegerType::get(72), (TypeBuilder<types::i<72>, true>::get(getGlobalContext())));
+ EXPECT_EQ(IntegerType::get(72), (TypeBuilder<types::i<72>, false>::get(getGlobalContext())));
}
TEST(TypeBuilderTest, Float) {
- EXPECT_EQ(Type::FloatTy, (TypeBuilder<float, false>::get()));
- EXPECT_EQ(Type::DoubleTy, (TypeBuilder<double, false>::get()));
+ EXPECT_EQ(Type::FloatTy, (TypeBuilder<float, false>::get(getGlobalContext())));
+ EXPECT_EQ(Type::DoubleTy, (TypeBuilder<double, false>::get(getGlobalContext())));
// long double isn't supported yet.
- EXPECT_EQ(Type::FloatTy, (TypeBuilder<types::ieee_float, true>::get()));
- EXPECT_EQ(Type::FloatTy, (TypeBuilder<types::ieee_float, false>::get()));
- EXPECT_EQ(Type::DoubleTy, (TypeBuilder<types::ieee_double, true>::get()));
- EXPECT_EQ(Type::DoubleTy, (TypeBuilder<types::ieee_double, false>::get()));
- EXPECT_EQ(Type::X86_FP80Ty, (TypeBuilder<types::x86_fp80, true>::get()));
- EXPECT_EQ(Type::X86_FP80Ty, (TypeBuilder<types::x86_fp80, false>::get()));
- EXPECT_EQ(Type::FP128Ty, (TypeBuilder<types::fp128, true>::get()));
- EXPECT_EQ(Type::FP128Ty, (TypeBuilder<types::fp128, false>::get()));
- EXPECT_EQ(Type::PPC_FP128Ty, (TypeBuilder<types::ppc_fp128, true>::get()));
- EXPECT_EQ(Type::PPC_FP128Ty, (TypeBuilder<types::ppc_fp128, false>::get()));
+ EXPECT_EQ(Type::FloatTy, (TypeBuilder<types::ieee_float, true>::get(getGlobalContext())));
+ EXPECT_EQ(Type::FloatTy, (TypeBuilder<types::ieee_float, false>::get(getGlobalContext())));
+ EXPECT_EQ(Type::DoubleTy, (TypeBuilder<types::ieee_double, true>::get(getGlobalContext())));
+ EXPECT_EQ(Type::DoubleTy, (TypeBuilder<types::ieee_double, false>::get(getGlobalContext())));
+ EXPECT_EQ(Type::X86_FP80Ty, (TypeBuilder<types::x86_fp80, true>::get(getGlobalContext())));
+ EXPECT_EQ(Type::X86_FP80Ty, (TypeBuilder<types::x86_fp80, false>::get(getGlobalContext())));
+ EXPECT_EQ(Type::FP128Ty, (TypeBuilder<types::fp128, true>::get(getGlobalContext())));
+ EXPECT_EQ(Type::FP128Ty, (TypeBuilder<types::fp128, false>::get(getGlobalContext())));
+ EXPECT_EQ(Type::PPC_FP128Ty, (TypeBuilder<types::ppc_fp128, true>::get(getGlobalContext())));
+ EXPECT_EQ(Type::PPC_FP128Ty, (TypeBuilder<types::ppc_fp128, false>::get(getGlobalContext())));
}
TEST(TypeBuilderTest, Derived) {
EXPECT_EQ(PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty)),
- (TypeBuilder<int8_t**, false>::get()));
+ (TypeBuilder<int8_t**, false>::get(getGlobalContext())));
EXPECT_EQ(ArrayType::get(Type::Int8Ty, 7),
- (TypeBuilder<int8_t[7], false>::get()));
+ (TypeBuilder<int8_t[7], false>::get(getGlobalContext())));
EXPECT_EQ(ArrayType::get(Type::Int8Ty, 0),
- (TypeBuilder<int8_t[], false>::get()));
+ (TypeBuilder<int8_t[], false>::get(getGlobalContext())));
EXPECT_EQ(PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty)),
- (TypeBuilder<types::i<8>**, false>::get()));
+ (TypeBuilder<types::i<8>**, false>::get(getGlobalContext())));
EXPECT_EQ(ArrayType::get(Type::Int8Ty, 7),
- (TypeBuilder<types::i<8>[7], false>::get()));
+ (TypeBuilder<types::i<8>[7], false>::get(getGlobalContext())));
EXPECT_EQ(ArrayType::get(Type::Int8Ty, 0),
- (TypeBuilder<types::i<8>[], false>::get()));
+ (TypeBuilder<types::i<8>[], false>::get(getGlobalContext())));
EXPECT_EQ(PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty)),
- (TypeBuilder<types::i<8>**, true>::get()));
+ (TypeBuilder<types::i<8>**, true>::get(getGlobalContext())));
EXPECT_EQ(ArrayType::get(Type::Int8Ty, 7),
- (TypeBuilder<types::i<8>[7], true>::get()));
+ (TypeBuilder<types::i<8>[7], true>::get(getGlobalContext())));
EXPECT_EQ(ArrayType::get(Type::Int8Ty, 0),
- (TypeBuilder<types::i<8>[], true>::get()));
+ (TypeBuilder<types::i<8>[], true>::get(getGlobalContext())));
EXPECT_EQ(Type::Int8Ty,
- (TypeBuilder<const int8_t, false>::get()));
+ (TypeBuilder<const int8_t, false>::get(getGlobalContext())));
EXPECT_EQ(Type::Int8Ty,
- (TypeBuilder<volatile int8_t, false>::get()));
+ (TypeBuilder<volatile int8_t, false>::get(getGlobalContext())));
EXPECT_EQ(Type::Int8Ty,
- (TypeBuilder<const volatile int8_t, false>::get()));
+ (TypeBuilder<const volatile int8_t, false>::get(getGlobalContext())));
EXPECT_EQ(Type::Int8Ty,
- (TypeBuilder<const types::i<8>, false>::get()));
+ (TypeBuilder<const types::i<8>, false>::get(getGlobalContext())));
EXPECT_EQ(Type::Int8Ty,
- (TypeBuilder<volatile types::i<8>, false>::get()));
+ (TypeBuilder<volatile types::i<8>, false>::get(getGlobalContext())));
EXPECT_EQ(Type::Int8Ty,
- (TypeBuilder<const volatile types::i<8>, false>::get()));
+ (TypeBuilder<const volatile types::i<8>, false>::get(getGlobalContext())));
EXPECT_EQ(Type::Int8Ty,
- (TypeBuilder<const types::i<8>, true>::get()));
+ (TypeBuilder<const types::i<8>, true>::get(getGlobalContext())));
EXPECT_EQ(Type::Int8Ty,
- (TypeBuilder<volatile types::i<8>, true>::get()));
+ (TypeBuilder<volatile types::i<8>, true>::get(getGlobalContext())));
EXPECT_EQ(Type::Int8Ty,
- (TypeBuilder<const volatile types::i<8>, true>::get()));
+ (TypeBuilder<const volatile types::i<8>, true>::get(getGlobalContext())));
EXPECT_EQ(PointerType::getUnqual(Type::Int8Ty),
- (TypeBuilder<const volatile int8_t*const volatile, false>::get()));
+ (TypeBuilder<const volatile int8_t*const volatile, false>::get(getGlobalContext())));
}
TEST(TypeBuilderTest, Functions) {
std::vector<const Type*> params;
EXPECT_EQ(FunctionType::get(Type::VoidTy, params, false),
- (TypeBuilder<void(), true>::get()));
+ (TypeBuilder<void(), true>::get(getGlobalContext())));
EXPECT_EQ(FunctionType::get(Type::Int8Ty, params, true),
- (TypeBuilder<int8_t(...), false>::get()));
- params.push_back(TypeBuilder<int32_t*, false>::get());
+ (TypeBuilder<int8_t(...), false>::get(getGlobalContext())));
+ params.push_back(TypeBuilder<int32_t*, false>::get(getGlobalContext()));
EXPECT_EQ(FunctionType::get(Type::Int8Ty, params, false),
- (TypeBuilder<int8_t(const int32_t*), false>::get()));
+ (TypeBuilder<int8_t(const int32_t*), false>::get(getGlobalContext())));
EXPECT_EQ(FunctionType::get(Type::Int8Ty, params, true),
- (TypeBuilder<int8_t(const int32_t*, ...), false>::get()));
- params.push_back(TypeBuilder<char*, false>::get());
+ (TypeBuilder<int8_t(const int32_t*, ...), false>::get(getGlobalContext())));
+ params.push_back(TypeBuilder<char*, false>::get(getGlobalContext()));
EXPECT_EQ(FunctionType::get(Type::Int8Ty, params, false),
- (TypeBuilder<int8_t(int32_t*, void*), false>::get()));
+ (TypeBuilder<int8_t(int32_t*, void*), false>::get(getGlobalContext())));
EXPECT_EQ(FunctionType::get(Type::Int8Ty, params, true),
- (TypeBuilder<int8_t(int32_t*, char*, ...), false>::get()));
- params.push_back(TypeBuilder<char, false>::get());
+ (TypeBuilder<int8_t(int32_t*, char*, ...), false>::get(getGlobalContext())));
+ params.push_back(TypeBuilder<char, false>::get(getGlobalContext()));
EXPECT_EQ(FunctionType::get(Type::Int8Ty, params, false),
- (TypeBuilder<int8_t(int32_t*, void*, char), false>::get()));
+ (TypeBuilder<int8_t(int32_t*, void*, char), false>::get(getGlobalContext())));
EXPECT_EQ(FunctionType::get(Type::Int8Ty, params, true),
- (TypeBuilder<int8_t(int32_t*, char*, char, ...), false>::get()));
- params.push_back(TypeBuilder<char, false>::get());
+ (TypeBuilder<int8_t(int32_t*, char*, char, ...), false>::get(getGlobalContext())));
+ params.push_back(TypeBuilder<char, false>::get(getGlobalContext()));
EXPECT_EQ(FunctionType::get(Type::Int8Ty, params, false),
- (TypeBuilder<int8_t(int32_t*, void*, char, char), false>::get()));
+ (TypeBuilder<int8_t(int32_t*, void*, char, char), false>::get(getGlobalContext())));
EXPECT_EQ(FunctionType::get(Type::Int8Ty, params, true),
(TypeBuilder<int8_t(int32_t*, char*, char, char, ...),
- false>::get()));
- params.push_back(TypeBuilder<char, false>::get());
+ false>::get(getGlobalContext())));
+ params.push_back(TypeBuilder<char, false>::get(getGlobalContext()));
EXPECT_EQ(FunctionType::get(Type::Int8Ty, params, false),
(TypeBuilder<int8_t(int32_t*, void*, char, char, char),
- false>::get()));
+ false>::get(getGlobalContext())));
EXPECT_EQ(FunctionType::get(Type::Int8Ty, params, true),
(TypeBuilder<int8_t(int32_t*, char*, char, char, char, ...),
- false>::get()));
+ false>::get(getGlobalContext())));
}
class MyType {
@@ -163,14 +164,14 @@
namespace llvm {
template<bool cross> class TypeBuilder<MyType, cross> {
public:
- static const StructType *get() {
+ static const StructType *get(LLVMContext &Context) {
// Using the static result variable ensures that the type is
// only looked up once.
- static const StructType *const result = StructType::get(
- TypeBuilder<int, cross>::get(),
- TypeBuilder<int*, cross>::get(),
- TypeBuilder<void*[], cross>::get(),
- NULL);
+ std::vector<const Type*> st;
+ st.push_back(TypeBuilder<int, cross>::get(Context));
+ st.push_back(TypeBuilder<int*, cross>::get(Context));
+ st.push_back(TypeBuilder<void*[], cross>::get(Context));
+ static const StructType *const result = Context.getStructType(st);
return result;
}
@@ -186,14 +187,14 @@
template<bool cross> class TypeBuilder<MyPortableType, cross> {
public:
- static const StructType *get() {
+ static const StructType *get(LLVMContext &Context) {
// Using the static result variable ensures that the type is
// only looked up once.
- static const StructType *const result = StructType::get(
- TypeBuilder<types::i<32>, cross>::get(),
- TypeBuilder<types::i<32>*, cross>::get(),
- TypeBuilder<types::i<8>*[], cross>::get(),
- NULL);
+ std::vector<const Type*> st;
+ st.push_back(TypeBuilder<types::i<32>, cross>::get(Context));
+ st.push_back(TypeBuilder<types::i<32>*, cross>::get(Context));
+ st.push_back(TypeBuilder<types::i<8>*[], cross>::get(Context));
+ static const StructType *const result = Context.getStructType(st);
return result;
}
@@ -211,23 +212,23 @@
TEST(TypeBuilderTest, Extensions) {
EXPECT_EQ(PointerType::getUnqual(StructType::get(
- TypeBuilder<int, false>::get(),
- TypeBuilder<int*, false>::get(),
- TypeBuilder<void*[], false>::get(),
+ TypeBuilder<int, false>::get(getGlobalContext()),
+ TypeBuilder<int*, false>::get(getGlobalContext()),
+ TypeBuilder<void*[], false>::get(getGlobalContext()),
NULL)),
- (TypeBuilder<MyType*, false>::get()));
+ (TypeBuilder<MyType*, false>::get(getGlobalContext())));
EXPECT_EQ(PointerType::getUnqual(StructType::get(
- TypeBuilder<types::i<32>, false>::get(),
- TypeBuilder<types::i<32>*, false>::get(),
- TypeBuilder<types::i<8>*[], false>::get(),
+ TypeBuilder<types::i<32>, false>::get(getGlobalContext()),
+ TypeBuilder<types::i<32>*, false>::get(getGlobalContext()),
+ TypeBuilder<types::i<8>*[], false>::get(getGlobalContext()),
NULL)),
- (TypeBuilder<MyPortableType*, false>::get()));
+ (TypeBuilder<MyPortableType*, false>::get(getGlobalContext())));
EXPECT_EQ(PointerType::getUnqual(StructType::get(
- TypeBuilder<types::i<32>, false>::get(),
- TypeBuilder<types::i<32>*, false>::get(),
- TypeBuilder<types::i<8>*[], false>::get(),
+ TypeBuilder<types::i<32>, false>::get(getGlobalContext()),
+ TypeBuilder<types::i<32>*, false>::get(getGlobalContext()),
+ TypeBuilder<types::i<8>*[], false>::get(getGlobalContext()),
NULL)),
- (TypeBuilder<MyPortableType*, true>::get()));
+ (TypeBuilder<MyPortableType*, true>::get(getGlobalContext())));
}
} // anonymous namespace
More information about the llvm-commits
mailing list