<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, May 28, 2014 at 6:42 AM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, May 27, 2014 at 6:28 PM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br>

> On Sat, May 24, 2014 at 8:28 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>><br>
> wrote:<br>
>><br>
>> > My first idea is to add a tablegen property like "HasPrettyPrinter = 0<br>
>> > or 1"<br>
>> > that supresses emission of the default printPretty method.  Then again,<br>
>> > we<br>
>> > kind of want the default version when the GNU and C++11 spellings of the<br>
>> > attribute are used.<br>
>><br>
>> That seems like the wrong way to go about it though, since this is a<br>
>> new *spelling*, not a wholly new semantic kind of attribute (which I<br>
>> think we really want to avoid). We could possibly attach a custom<br>
>> pretty printer to the spelling itself (a la a code block), but that<br>
>> seems a bit skeezy because the arguments are rather important and the<br>
>> spelling shouldn't have to care about the arguments.<br>
><br>
><br>
> How about this: when generating the prettyPrint implementation, if there is<br>
> a pragma spelling, call MyAttr::printPrettyPragma(...).  Any attribute with<br>
> a pragma spelling will have to provide this method in lib/AST/AttrImpl.cpp.<br>
<br>
</div></div>So my ultimate goal is for pragma attributes to mirror all of the<br>
other attributes, where we can infer syntax and semantics just from<br>
what's in Attr.td. But it's becoming more obvious to me that the<br>
amount of work required to get there is rather large (mostly due to<br>
the fact that pragma argument syntax is ALL over the place).<br>
<br>
As a stopgap solution, it seems reasonable to me to rely on an<br>
AdditionalMember being defined for pragmas (which is basically what<br>
you're suggesting).<br>
<br>
So if an attribute has a pragma spelling, it is required to have:<br>
<br>
let AdditionalMembers = [{<br>
  void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {<br>
  }<br>
}];<br></blockquote><div><br></div><div>Sure, but... I like writing C++ in .cpp files, not .td files.  +1 for defining it out of line in AttrImpl.cpp.  :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Then in ClangAttrEmitter.cpp, the printPretty generator function can<br>
simply call through to this for a pragma spelling in<br>
writePrettyPrintFunction. If the attribute has no AdditionalMembers<br>
field, the generator can spit out a friendly error, but if the author<br>
simply forgets the signature for this, a compile-time error will have<br>
to suffice.<br>
<br>
Someday, once we solve the parameter syntax issue, we can rip out the<br>
printPrettyPragma functions. That can be added as a FIXME to<br>
writePrettyPrintFunction.<br>
<span class="HOEnZb"><font color="#888888"><br>
~Aaron<br>
</font></span></blockquote></div><br></div></div>