-1

Can any one please help me in finding the actual argument names of printf() call from LLVM-IR.

For example : I am having printf("%d,%d,x,y); statement in program.

I am writing LLVM pass for finding actual argument names (x and y in above example).

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Please check http://stackoverflow.com/help/mcve to see How to create a Minimal, Complete, and Verifiable example – pringi Feb 03 '17 at 13:56

1 Answers1

1

One way of doing it is by using CallExpr to identify printf calls.
You would use getArgs() instead of getArg(0) and use an iterator to parse through the arguments.

const Expr* expr = CE->getArg(0); //CE is the CallExpr for printf
if (const ImplicitCaseExpr* ICE = 
             llvm::dyn_cast<ImplicitCastExpr>(expr)) {
     const Expr* DRE_VAR = ICE->getSubExpr();
     //now, cast and parse the AST
}

EDIT: Looking at this a couple of months later, I can tell you that the only way to do this would be for you to do the placeholder mapping.

Yolo Voe
  • 495
  • 6
  • 22