[cfe-dev] Getting FunctionDecl argument name as string
Aleksei Sidorin
a.sidorin at samsung.com
Sat Jun 21 03:11:29 PDT 2014
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
More information about the cfe-dev
mailing list