I am trying to write a plugin for clang or gcc to interpret custom [[cxx11 :: attributes]] and generate some code based on this.
Starting with version 4.5, gcc supports plugins that can be connected at almost every stage of compilation. However, I think gcc doesn't really know how to modify its AST and navigate it (at least I'm having a bad time trying ...).
Then I remembered that clang was designed to be expanded and used as a library, and I gave it a chance. After digging, I found several topics saying that clang does not support user attributes. I cried.
My main goal is to generate code based on any annotations that the user can use in the code. I would like to use C ++ 11 attributes because they are very clear. Pragmas are also an option, but they have some limitations.
Here are the questions:
1) Is it (currently) impossible to have custom attributes in clang? 2) What is the best way to learn gcc internals? (I read a lot of documentation pages, but still they didn’t say what I want) 3) Does gcc have some kind of dump function for printing its AST, how does clang do it? This will help a lot to study its tree.
Thanks! Any info / tip would be appreciated!
source share