[cfe-users] Unknown type name becomes int when generate AST
David Blaikie
dblaikie at gmail.com
Mon Jul 13 09:05:29 PDT 2015
On Tue, Jul 7, 2015 at 3:21 AM, 易源 <vania_yyyy at 126.com> wrote:
> Hi,
>
> 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.
>
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...
> It's all good unless there is some unknown type name exists. For example,
> my_type foo(int x) { /*...*/ } // "my_type" is just a type identifier
> whose definition is missed in this translation unit.
> When I use getReturnType() in RecursiveASTVisitor::VisitFunctionDecl(), it
> will return type "int". So my program will output
> int foo(int x);
> instead of
> my_type foo(int x);
> I'm curious why "my_type" will be parsed as of type "int".
> 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).
>
> Thanks!
>
>
>
> _______________________________________________
> cfe-users mailing list
> cfe-users at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20150713/93fd85b4/attachment.html>
More information about the cfe-users
mailing list