[cfe-dev] Adding a new def for global keyword in Attr.td

Aaron Ballman aaron at aaronballman.com
Thu Oct 30 07:06:05 PDT 2014


On Wed, Oct 29, 2014 at 9:40 PM, Aaron W.Hsu <arcfide at sacrideo.us> wrote:
> Dear Aaron:
>
> Thank you for clarifying that I can’t have a global keyword around
> clobbering the OpenCL global keyword. If I might ask then, what is the best
> way to handle this? Should I just rename OpenCLGlobalAddressSpace to
> GlobalAddressSpace or some such and then handle them as appropriate
> depending on whether I’m in one language mode or the other? Or is there some
> other better way of dealing with this?

Is your attribute a type attribute, or is it a declaration attribute?
If it's a type attribute and works in the same way as OpenCL's (which
is an address space attribute), you could probably just rename. If
it's significantly different from OpenCL's, you may have to implement
custom parsing logic and handle this at the parsing stage instead of
the sema stage depending on whether it's an OpenCL global or your
global.  So instead of adding an attribute with a spelling, as in
Parser::ParseOpenCLQualifiers, you would create your attribute
implicitly. See Sema::AddAlignmentAttributesForRecord for an example
of how that happens. The downside to this is that the attribute isn't
really implicit, so things like pretty printing can be mucked up.

~Aaron




More information about the cfe-dev mailing list