Hi,<br><br><div class="gmail_quote">On Fri, Jan 11, 2013 at 3:53 PM, Michael Han <span dir="ltr"><<a href="mailto:fragmentshaders@gmail.com" target="_blank">fragmentshaders@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br><br>Attached patch is to fix PR14922. Currently when print an attribute the GNU syntax will always be used, even if the attribute has no GNU syntax.The fix is to pass the syntax flag when constructing the Attr node and take that into consideration when printing the attribute. The name of actual attribute gets printed is read from table gen definition file so there is still some limitations, for example, when an attribute has multiple spellings, the first spelling is used; and the namespace of the attribute (in case it's a C++11 attribute) is not printed. I test the patch locally in my project which has access to Clang AST but I am not sure how to write a stand alone test to test the attribute pretty print.  After this patch gets in I'll send another patch which updates the SemaDeclAttr to pass the actual syntax flag from AttributeList to Attr.</blockquote>
<div><br></div><div>I don't think this is the best approach: it still always uses the first spelling, so it still won't produce the right string for __attribute__((aligned(...))) versus __declspec(alignment(...)) versus [[gnu::aligned(...)]] versus alignas(...).</div>
<div><br></div><div>Since we already have a list of possible spellings for an attribute in the attribute definition (which incorporates the syntax used), how about just storing an index into that list on the Attr?</div></div>