[LLVMdev] How To Get The Name of the type the popinter is pointing to
Vinay M
mvinay05041990 at gmail.com
Thu Sep 20 21:08:38 PDT 2012
amitjai wrote
> i am using llvm ,
> i did this
>
> if ( AllocaInst *allocInst = dyn_cast
> <AllocaInst>
> (&*bbit)){
> PointerType *p = allocInst->getType();
> if ( p->getElementType()->isPointerTy()){
> StringRef name =
> allocInst->getName();
> Type *type =
> allocInst->getOperand(0)->getType();;
> errs() << type->getName() << " "
> << name << "\n";
> }
> }
>
> but i am getting the output in the following format
>
> i32 line
> i32 temp
> i32 p
> i32 filename
> i32 arrays
> i32 label
> i32 fp
> i32 head
> i32 b
>
> here line is char* ,temp is char* , p is int pointer,fp is file pointer
> ,head is pointer to list node structure and so on
>
> but why i am getting i32 for all the pointers .
>
> please help me out.
Hi ,
I am using the following code to get the Type of Pointer element allocated-
if ( (AllocaInst *AI = dyn_cast<AllocaInst> (Inst)) )
if ( AI->getType()->getElementType()->isPointerTy() )
errs() << "\nType :- " << *AI->getType()->getElementType()
<< "\tName:- " << AI->getName();
"allocInst->getOperand(0)" contains the number of elements of that type to
be allocated , so its type is always i32..
--
View this message in context: http://llvm.1065342.n5.nabble.com/How-To-Get-The-Name-of-the-type-the-popinter-is-pointing-to-tp49121p49159.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
More information about the llvm-dev
mailing list