[cfe-dev] Clang returns Parameter names instead of Arguments
Piotr Padlewski via cfe-dev
cfe-dev at lists.llvm.org
Sun Aug 7 10:02:49 PDT 2016
That's pretty weird. I would also not expect it to happen and I would also
like to know the answer.
2016-08-07 6:06 GMT-07:00 Dhriti Khanna via cfe-dev <cfe-dev at lists.llvm.org>
:
> Hello,
>
> I want to print the arguments passed to a function. But clang returns
> Parameter names used in the function definition. Here is my 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";
> }
> }
> Example:
> int iArgument = 123;
> char cArgument = 'c';
> foo(iArgument, cArgument);
> For this code, it should print iArgument and cArgument, but it is printing
> the names of the parameters given in function definition.
>
> Please tell what might be the problem.
>
> Also, I am able to get the arguments' name when I am using a simple C++
> code. But when I start using another library's API (for that I am
> specifying compile_commands.json file), this presents problems.
>
> --
> Regards,
> Dhriti Khanna
> PhD Scholar
> IIIT Delhi
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160807/62b49af5/attachment.html>
More information about the cfe-dev
mailing list