<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 7, 2015 at 3:21 AM, 易源 <span dir="ltr"><<a href="mailto:vania_yyyy@126.com" target="_blank">vania_yyyy@126.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi,<br><br>I'm trying to use clang's ParseAST() and ASTConsumer to extract all c function declarations in a source file, and then output these function declarations into another file. <br></div></div></blockquote><div><br></div><div>Chances are you should have your tool fail if the code isn't successfully parsed - otherwise the AST will be in all manner of invalid states that you'll have to check for... </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>It's all good unless there is some unknown type name exists. For example,<br>  my_type foo(int x) { /*...*/ }    // "my_type" is just a type identifier whose definition is missed in this translation unit.<br>When I use getReturnType() in RecursiveASTVisitor::VisitFunctionDecl(), it will return type "int". So my program will output<br>  int foo(int x);<br>instead of<br>  my_type foo(int x);<br>I'm curious why "my_type" will be parsed as of type "int". <br>When parsing this source code, clang will report an error saying "error: unknown type name 'my_type'". So I think clang knows it's a type (unknown type is also a type I think).<br><br>Thanks!<br></div></div><br><br><span title="neteasefooter"><span></span></span><br>_______________________________________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@cs.uiuc.edu">cfe-users@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users</a><br>
<br></blockquote></div><br></div></div>