[PATCH] Add PragmaAttr and Pragma Spelling to Tablegen

Aaron Ballman aaron at aaronballman.com
Sat May 24 08:28:09 PDT 2014


On Fri, May 23, 2014 at 5:41 PM, Reid Kleckner <rnk at google.com> wrote:
> A pragma spelling makes a lot of sense to me.  We have lots of attributes
> (optimize, section, cf_audited_transfer) that are applied implicitly by
> pragmas, and it would be good to render them that way in diagnostics.
>
> I'm not convinced we need a PragmaAttr base class for pretty printing.
> Maybe we need some other mechanism for allowing attributes to provide custom
> pretty printers.  Aaron, what do you think?

I'm agreed that we don't want a base class, especially for pretty
printing. As for custom pretty printing, that would be unfortunate to
require, but may be necessary nonetheless.

> My first idea is to add a tablegen property like "HasPrettyPrinter = 0 or 1"
> that supresses emission of the default printPretty method.  Then again, we
> kind of want the default version when the GNU and C++11 spellings of the
> attribute are used.

That seems like the wrong way to go about it though, since this is a
new *spelling*, not a wholly new semantic kind of attribute (which I
think we really want to avoid). We could possibly attach a custom
pretty printer to the spelling itself (a la a code block), but that
seems a bit skeezy because the arguments are rather important and the
spelling shouldn't have to care about the arguments.

~Aaron



More information about the cfe-commits mailing list