X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=unittests%2FIR%2FConstantsTest.cpp;h=7471584097ddaa351571836e1d001e879c6ae849;hb=d0dc794073ee74622a4af86e5553d7926e4b8aec;hp=0bf98f35b3c8148150635e776bc8793d0d3ced5d;hpb=4381284cf88991a0971886daa914225539c570e5;p=oota-llvm.git diff --git a/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp index 0bf98f35b3c..7471584097d 100644 --- a/unittests/IR/ConstantsTest.cpp +++ b/unittests/IR/ConstantsTest.cpp @@ -15,6 +15,7 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/Support/SourceMgr.h" +#include "llvm-c/Core.h" #include "gtest/gtest.h" namespace llvm { @@ -433,5 +434,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