LibTooling for parsing C++ that uses unknown attributes

Hello,

I’m starting an experimental project to generate code to marshal and unmarshal C++ data. The goal would be a tool that would parse the header files, and then write the necessary methods. I started an implementation using LibTooling, but found that the custom attributes would not available. Going back to the documentation, this appears to be the correct behaviour.

Before I decide that I need a fork of libclang, is there a way to add attributes to the compiler when using LibTooling, or to request that unknown attributes are kept and present in the AST?

Thank-you,

Robert

+benjamin, who might have good ideas

+aaron

I don't think we currently have a way to expose custom attributes in
the AST without patching Attr.td. Some workarounds exists, like using
a comment as your attribute and checking for its (textual) presence.
Another option is the generic "annotate" attribute, which is intended
to be a attribute for random strings to be consumed by a tool or LLVM
IR pass.

- Ben

+aaron

I don't think we currently have a way to expose custom attributes in
the AST without patching Attr.td. Some workarounds exists, like using
a comment as your attribute and checking for its (textual) presence.
Another option is the generic "annotate" attribute, which is intended
to be a attribute for random strings to be consumed by a tool or LLVM
IR pass.

There is not currently a way to do this with the attribute subsystem,
but a pluggable attribute system is desirable. I have ideas in mind of
how I would like to see something like this look, but have never had
the time to work on it. In the meantime, I think the annotate
attribute is the closest you'll be able to come with what we have
today.

~Aaron