[cfe-dev] 回复: how to determine a parameter has a type declarator in clang
kevinlynx
kevinlynx at gmail.com
Wed Jan 2 04:31:01 PST 2013
but how to get a DeclaratorChunk in my codes ?
------------------ 原始邮件 ------------------
发件人: "Nikola Smiljanic"<popizdeh at gmail.com>;
发送时间: 2013年1月2日(星期三) 下午2:15
收件人: "kevinlynx"<kevinlynx at gmail.com>;
抄送: "cfe-dev"<cfe-dev at cs.uiuc.edu>;
主题: Re: [cfe-dev] how to determine a parameter has a type declarator in clang
I think you need a DeclaratorChunk that represents the function (Kind
== DeclaratorChunk::Function). Then you access the Fun union member.
On Wed, Jan 2, 2013 at 1:10 AM, kevinlynx <kevinlynx at gmail.com> wrote:
> Thanks for your reply. But i still can not figure it out. I get function
> declaration by these codes below:
>
> class MyASTVisitor : public RecursiveASTVisitor<MyASTVisitor>
> {
> public:
> bool VisitFunctionDecl(FunctionDecl *f) {
> for (FunctionDecl::param_iterator it = f->param_begin(); it !=
> f->param_end(); ++it) {
> ParmVarDecl *p = *it;
> ...
> }
> return true;
> }
> };
>
> which means I only get `FunctionDecl` object. I do not know how to get a
> `FunctionTypeInfo` you mentioned. Maybe I 'm not on the right way to parse a
> function definition/declaration.
>
> BTW, I'm writing a static code analyzer tool, and i will check whether a
> function parameter has a type declarator.
>
>
>
> ------------------ 原始邮件 ------------------
> 发件人: "Nikola Smiljanic"<popizdeh at gmail.com>;
> 发送时间: 2013年1月1日(星期二) 晚上7:56
> 收件人: "kevinlynx"<kevinlynx at gmail.com>;
> 抄送: "cfe-dev"<cfe-dev at cs.uiuc.edu>;
> 主题: Re: [cfe-dev] how to determine a parameter has a type declarator in
> clang
>
> Have a look at ArgInfo member of FunctionTypeInfo, the comment for ParamInfo
> structure has the relevant part:
>
> /// ParamInfo - An array of paraminfo objects is allocated whenever a
> function
> /// declarator is parsed. There are two interesting styles of arguments
> here:
> /// K&R-style identifier lists and parameter type lists. K&R-style
> identifier
> /// lists will have information about the identifier, but no type
> information.
> /// Parameter type lists will have type info (if the actions module provides
> /// it), but may have null identifier info: e.g. for 'void foo(int X, int)'.
>
> On Mon, Dec 31, 2012 at 6:40 PM, kevinlynx <kevinlynx at gmail.com> wrote:
>>
>>
>> I use clang to do some code analyse. And now i have a function below
>>
>> void func(p)
>>
>> some compilers will process p as an integer. And i want to know how to
>> determine whether p has a type declarator ?
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130102/7a9cfc45/attachment.html>
More information about the cfe-dev
mailing list