[LLVMdev] GetElementPtrConstantExpr

Óscar Fuentes ofv at wanadoo.es
Tue Dec 18 09:40:53 PST 2012

Alessio Giovanni Baroni <alessiogiovanni.baroni at gmail.com> writes:

> Because I need to convert an [4 x i8] type to i8* in the instantiation of a
> GlobalVariable.
> I have the follow declaration: %xxx = type { i8* } and I must emit the
> following variable:
> @yyy = linkonce_odr constant %xxx { [4 x i8] c"hello\00" }, but it's wrong.
> How do I do?

You can use the ConstantExpr::getBitCast static member function:


This is a common idiom on LLVM: a base class has static methods for
creating instances of derived classes.

More information about the llvm-dev mailing list