clang++ - Clang returns Parameter names instead of Arguments -


i want print arguments passed in function. clang returns parameter names used in function definition. here code:

if (callexpr *call = dyn_cast<callexpr>(st))  {      langoptions langopts;     langopts.cplusplus = true;     printingpolicy policy(langopts);      for(int i=0, j=call->getnumargs(); i<j; i++)     {         std::string types;         raw_string_ostream raw(types);         call->getarg(i)->printpretty(raw, 0, policy);         errs() << raw.str() << "\n";     } } 

please tell might problem.

when comes arguments, there many possibilities. assume dealing simplest case, like:

int iargument = 123; char cargument = 'c'; foo(iargument, cargument); 

several castings necessary arguments' info

for (unsigned = 0; < call->getnumargs(); ++i) {     if (auto cast = dyn_cast<implicitcastexpr>(call->getarg(i))) {         if (auto arg = dyn_cast<declrefexpr>(cast->getsubexpr())) {             arg->getnameinfo().getname().dump();         }     } } 

Comments