18

I have an object of type CallInst. How can I get the name of the called function (aka callee). Assume the function is called directly (i.e., no indirect function calls).

A. K.
  • 34,395
  • 15
  • 52
  • 89
pythonic
  • 20,589
  • 43
  • 136
  • 219

1 Answers1

25
StringRef get_function_name(CallInst *call)
{
    Function *fun = call->getCalledFunction();
    if (fun) // thanks @Anton Korobeynikov
        return fun->getName(); // inherited from llvm::Value
    else
        return StringRef("indirect call");
}

anyway, that's what the documentation implies:

Useless
  • 64,155
  • 6
  • 88
  • 132