<font face="tahoma,sans-serif">Hi all,</font><div><font face="tahoma,sans-serif"><br></font></div><div><font face="tahoma,sans-serif">I would like to have a go at hacking a little on Clang when a get a bit of spare time, and have found that adding support for override would be useful little exercise.  I've seen another post referring to Clang's support for __attribute__((override)), and seems like I could use this as a starting point.</font></div>
<div><font face="tahoma,sans-serif"><br></font></div><div><font face="tahoma,sans-serif"><a href="http://weblog.bignerdranch.com/?p=171">Big Nerd Ranch</a> would like to see an @override keyword, as follows:</font></div><div>
<font face="tahoma,sans-serif"><br></font></div><div><font face="tahoma,sans-serif"><meta charset="utf-8"><span class="Apple-style-span" style="font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 12px; color: rgb(48, 48, 48); line-height: 19px; "><pre class="code" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font-family: Courier; font-size: 1.2em; width: 672px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; border-color: initial; border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; ">
@override
- (NSInteger)numberOfSectionsInTableview:(UITableView *)tv
{ ... }</pre></span></font></div><div><font face="tahoma,sans-serif"><br></font></div><div><font face="tahoma,sans-serif">This would seem the most natural, but I feel it would involve mucking with the parser, the AST and therefore fairly complicated.  Given Clang already parses __attribute__, I could take the following approach instead:</font></div>
<div><font face="tahoma,sans-serif"><br></font></div><div><font class="Apple-style-span" face="tahoma, sans-serif"><meta charset="utf-8"><span class="Apple-style-span" style="font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 12px; color: rgb(48, 48, 48); line-height: 19px; "><pre class="code" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font-family: Courier; font-size: 1.2em; width: 672px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; border-color: initial; border-top-width: thin; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; ">
- (NSInteger)numberOfSectionsInTableview:(UITableView *)tv __attribute__((override))
{ ... }</pre></span></font></div><div><font class="Apple-style-span" face="tahoma, sans-serif"><br></font></div><div><font class="Apple-style-span" face="tahoma, sans-serif">Can I implement this as a Clang plugin or must I modify Clang source?</font></div>
<div><font class="Apple-style-span" face="tahoma, sans-serif"><br></font></div><div><font class="Apple-style-span" face="tahoma, sans-serif">One other question is I couldn't get Clang 2.8 to recognize __has_attribute(override) for a .cpp file:</font></div>
<div><font class="Apple-style-span" face="tahoma, sans-serif"><br></font></div><div><div><font class="Apple-style-span" face="'courier new', monospace">#ifndef __has_attribute         </font></div><div><font class="Apple-style-span" face="'courier new', monospace">  #define __has_attribute(x) 0</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">  #warning no __has_attribute support</font></div><div><font class="Apple-style-span" face="'courier new', monospace">#endif</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">#if __has_attribute(override)</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">    </span>#define OVERRIDE __attribute__((override))</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">#else</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">   </span>#warning No override attribute</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">#endif</font></div></div><div><font class="Apple-style-span" face="tahoma, sans-serif"><br></font></div><div><font class="Apple-style-span" face="tahoma, sans-serif">Would always output the two warnings.</font></div>
<div><font class="Apple-style-span" face="tahoma, sans-serif"><br></font></div><div><font class="Apple-style-span" face="tahoma, sans-serif">Cheers,</font></div><div><font class="Apple-style-span" face="tahoma, sans-serif"><br>
Stu</font></div><div><font face="tahoma,sans-serif"><br clear="all"></font><span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse;color:rgb(80, 0, 80)"><strong><span style="color:rgb(153, 204, 255)">Stuart Carnie, CTO</span></strong><br>
<span style="color:rgb(255, 102, 0)"><strong><a href="http://manomio.com/" style="color:rgb(255, 102, 0)" target="_blank">manomio</a> | in retro we trust!</strong></span></span><br>
</div>