[cfe-users] Unknown type name becomes int when generate AST

易源 vania_yyyy at 126.com
Tue Jul 7 03:21:59 PDT 2015


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.
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).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20150707/118cf40b/attachment.html>

More information about the cfe-users mailing list