[LLVMdev] Queries regarding function's arguments data type

teja tamboli tamboli.teja at gmail.com
Mon Feb 25 11:44:09 PST 2013


Hi all,

I am working on my Master's project in security and I am trying to iterate
over the argument list of the function. Basically I need to do following
things :

1.  Check data type of each argument of the argument list of the function.
2. Based on its data type like character array or integer array, pointer,
int, char, take different action.
3. I have added following code to check its data type.

// F is any function basically of type function *
 FunctionType *FTy = F->getFunctionType();
unsigned int numArgs = FTy->getNumParams();

//Currently just checking data type of the 0th argument. Eventually will be
running it in the loop from 0 to numArgs.
  errs() << "\n1 Argument type int 32 : " <<
FTy->getParamType(0)->isIntegerTy(32);
  errs() << "\n2 Argument type char : " <<
FTy->getParamType(0)->isIntegerTy(8);
  errs() << "\n4 Argument type pointer : " <<
FTy->getParamType(0)->isPointerTy();
  errs() << "\n5 Argument type array : " <<
FTy->getParamType(0)->isArrayTy();
  errs() << "\n6 Argument type structure : " <<
FTy->getParamType(0)->isStructTy();

I can just find these many data types for integer and characters. This just
tells me that parameter is of type pointer or array or structure.

My question is if function's parameter type is pointer / array, how can I
figure it out whether its character pointer or integer pointer?
Also if it is a array then how can I find size of the array?
In case of structure how to check exact structure definition I mean exactly
it is instance of which structure?

Please let me know.

Thanks,
--Teja
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130225/0721377b/attachment.html>


More information about the llvm-dev mailing list