}
}
-void bitcastToGEPHelper(bool useOpaquePointers) {
+TEST(ConstantsTest, BitcastToGEP) {
LLVMContext Context;
- Context.setOpaquePointers(useOpaquePointers);
std::unique_ptr<Module> M(new Module("MyModule", Context));
auto *i32 = Type::getInt32Ty(Context);
new GlobalVariable(*M, S, false, GlobalValue::ExternalLinkage, nullptr);
auto *PtrTy = PointerType::get(i32, 0);
auto *C = ConstantExpr::getBitCast(G, PtrTy);
- if (Context.supportsTypedPointers()) {
- EXPECT_EQ(cast<ConstantExpr>(C)->getOpcode(), Instruction::BitCast);
- } else {
- /* With opaque pointers, no cast is necessary. */
- EXPECT_EQ(C, G);
- }
-}
-
-TEST(ConstantsTest, BitcastToGEP) {
- bitcastToGEPHelper(true);
- bitcastToGEPHelper(false);
+ /* With opaque pointers, no cast is necessary. */
+ EXPECT_EQ(C, G);
}
bool foldFuncPtrAndConstToNull(LLVMContext &Context, Module *TheModule,
}
TEST(TypesTest, CopyPointerType) {
- LLVMContext COpaquePointers;
- COpaquePointers.setOpaquePointers(true);
+ LLVMContext C;
- PointerType *P1 = PointerType::get(COpaquePointers, 1);
+ PointerType *P1 = PointerType::get(C, 1);
EXPECT_TRUE(P1->isOpaque());
PointerType *P1C = PointerType::getWithSamePointeeType(P1, 1);
EXPECT_EQ(P1, P1C);
PointerType *P1C0 = PointerType::getWithSamePointeeType(P1, 0);
EXPECT_NE(P1, P1C0);
EXPECT_TRUE(P1C0->isOpaque());
-
- LLVMContext CTypedPointers;
- CTypedPointers.setOpaquePointers(false);
- Type *Int8 = Type::getInt8Ty(CTypedPointers);
- PointerType *P2 = PointerType::get(Int8, 1);
- EXPECT_FALSE(P2->isOpaque());
- PointerType *P2C = PointerType::getWithSamePointeeType(P2, 1);
- EXPECT_EQ(P2, P2C);
- EXPECT_FALSE(P2C->isOpaque());
- PointerType *P2C0 = PointerType::getWithSamePointeeType(P2, 0);
- EXPECT_NE(P2, P2C0);
- EXPECT_FALSE(P2C0->isOpaque());
}
TEST(TypesTest, TargetExtType) {