X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=unittests%2FIR%2FConstantsTest.cpp;h=e3b303a350db7317c611ba9beba907a942d4e04f;hp=0bf98f35b3c8148150635e776bc8793d0d3ced5d;hb=1d7a67937c4624967442dae997a6cd0c0a9c0b72;hpb=040ff9fa3ea79016a8e95c013adc52ce4cc7eee2 diff --git a/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp index 0bf98f35b3c..e3b303a350d 100644 --- a/unittests/IR/ConstantsTest.cpp +++ b/unittests/IR/ConstantsTest.cpp @@ -433,5 +433,22 @@ TEST(ConstantsTest, BuildConstantDataVectors) { } } +TEST(ConstantsTest, BitcastToGEP) { + LLVMContext Context; + std::unique_ptr M(new Module("MyModule", Context)); + + auto *i32 = Type::getInt32Ty(Context); + auto *U = StructType::create(Context, "Unsized"); + Type *EltTys[] = {i32, U}; + auto *S = StructType::create(EltTys); + + auto *G = new GlobalVariable(*M, S, false, + GlobalValue::ExternalLinkage, nullptr); + auto *PtrTy = PointerType::get(i32, 0); + auto *C = ConstantExpr::getBitCast(G, PtrTy); + ASSERT_EQ(dyn_cast(C)->getOpcode(), + Instruction::BitCast); +} + } // end anonymous namespace } // end namespace llvm