Clang AST parser treats name of unknown type as int

I tried to use clang ParseAST () and ASTConsumer to extract all c function declarations in a source file and then output those function declarations to another file.

This is all well and good if there is no unknown type name. 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 () on RecursiveASTVisitor :: VisitFunctionDecl () it will return "int" type. So my program outputs

int foo(int x);

      

instead

my_type foo(int x);

      

I am curious why "my_type"

would be parsed as a type int

. When parsing this source code, clang will report an error with the error message:

unknown type name 'my_type'

... So I think clang knows it is a type (the unknown type is also a type, which I think).

+3


source to share


1 answer


This thread is too old, but is there a solution for this libclang problem?



0


source







All Articles