[cfe-dev] LibTooling for parsing C++ that uses unknown attributes

Aaron Ballman via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 7 05:42:30 PST 2016


On Thu, Jan 7, 2016 at 5:22 AM, Benjamin Kramer <benny.kra at gmail.com> wrote:
> +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

>
> - Ben
>
> On Tue, Jan 5, 2016 at 9:26 PM, Robert W. Johnstone via cfe-dev
> <cfe-dev at lists.llvm.org> wrote:
>> 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
>>
>>
>> --
>> ----------------------------------------
>> Robert W. Johnstone
>> In theory, there is no difference between theory and practice.
>> In practice, there is.
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>



More information about the cfe-dev mailing list