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