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
my_tool.cpp (4.26 KB)
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.
No, I could see your code, but you don’t have anything from the SO post in your code.
So if you describe what the exact PROBLEM is that you are seeing when you try to implement that, then perhaps someone can help (I have a basic understanding of AST’s and their visitors, but by no means an expert, so if it’s complicated, I may not know how to fix it)
Also, use reply-all when replying, so that here is a copy going to the mailing list, otherwise someone else may well ask/answer/comment the same thing again, which is a waste of time.