[cfe-dev] Implement AST visitor, avoid visiting included header files

mats petersson via cfe-dev cfe-dev at lists.llvm.org
Thu Jun 23 08:08:05 PDT 2016


What in the solution from SO is it that you can't make work? I can't see
the implementation in your code, so I can't explain what, if anything is
wrong with your code.

Clearly, the compiler will have to parse header files to be able to compile
any [non-trivial] source file, since there are declarations and definitions
there that are required to compile the whole source. So the only way to
determine if the AST is part of your main file is to use a filter to say
"is this from the main file or from a header" on each (top level) AST
entry, which is what the SO code does.

--
Mats

On 23 June 2016 at 13:28, Andreas Georgiou via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hello,
>
> As you can see I want to implement an AST visitor to extract some specific
> nodes from the AST.
> Unfortunately my code traverses also the included header files which is
> something that I dont want because it prints me everything about them which
> is not what I want.
> For example I want to extract every function declaration or variable
> declaration and their correspondig types.
>
> I have found this solution in stackoverflow but I cannot make it work.
>
> http://stackoverflow.com/questions/10454075/avoid-traversing-included-system-libaries
> My code is based on this tutorial:
>
> https://kevinaboos.wordpress.com/2013/07/23/clang-tutorial-part-i-introduction/
>
> Please also find attached my code.
>
> Thank you for your help.
> Andreas Georgiou
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160623/700695ea/attachment.html>


More information about the cfe-dev mailing list