[cfe-dev] Getting FunctionDecl argument name as string

Sandeep K Chaudhary babbusandy2006 at gmail.com
Sat Jun 21 15:01:18 PDT 2014


Thanks, Nikola and Aleksei !

Yes, it works.

Regards,
Sandeep.


On Sat, Jun 21, 2014 at 6:11 AM, Aleksei Sidorin <a.sidorin at samsung.com>
wrote:

> Hello Sandeep,
> ParmVarDecl is a NamedDecl so I think you can use getName() method that
> returns StringRef:
> http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html#
> aaf790590f634520a99e0b45699fc45c3
> or getNameAsString that returns std::string:
> http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html#
> a99d453b314da693c106d5acbc598fc6c
>
>  Hi guys,
>>
>> In a FunctionDecl with body, I want to get all the argument names and
>> types.
>>
>> I am able to get these on console by printing to llvm::errs() as following
>>
>> *llvm::errs() << f->getParamDecl(i)->getOriginalType().getAsString() <<
>> "\n";*
>> *llvm::errs() << *f->getParamDecl(i)<< "\n";*
>>
>>
>> The first one is a string. However, I can not get the string for argument
>> name. Though, I am able to successfully print it using llvm::errs().
>>
>> Can someone please help me with it? If I can write it to some file stream,
>> that would also work.
>>
>> I looked at ParmVarDecl but I didn't find anything useful to achieve it.
>>
>>
>
> --
> Best regards,
> Aleksei Sidorin
> Software Engineer,
> IMSWL-IMCG, SRR, Samsung Electronics
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>



-- 
Thanks and regards,
Sandeep K Chaudhary.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140621/0ad2df09/attachment.html>


More information about the cfe-dev mailing list