[LLVMdev] about pointer type

John Criswell criswell at uiuc.edu
Thu Jan 28 07:08:59 PST 2010

winkzhang wrote:
> Dear all,
> In the early llvm version, we could use PointerType::get(Type::Int32Ty)) to
> get the pointer type. But in the latest llvm (version 2.6), it doesn't work.
> Compiler says "‘Int32Ty’ is not a member of ‘llvm::Type’".
> I've looked the doxygen document, however, I can't find an answer, would you
> please help me? Thanks!
To get an int32 pointer type, do the following:

const Type * Int32Type = IntegerType::getInt32Ty(getGlobalContext());

To get a pointer type to it within the default address space, do the 


FWIW, types now take a context.  getGlobalContext() is a global context 
that was added to aid backwards compatibility.  It may be better to get 
the context from somewhere else (the Module that you're modifying, for 
example) so that your code needs less updating when LLVM goes 

The getUnqual method gets an unqualified pointer type, which places the 
pointer within the default address space.

-- John T.

> -Wink

More information about the llvm-dev mailing list