<html><body bgcolor="#FFFFFF"><div>Hi Michael,</div><div><br></div><div>This sounds very interesting.  Do you have any documentation that explains the model that this exposes to programmers?</div><div><br><div>-Chris</div></div><div><br>On Jun 30, 2011, at 11:37 PM, Michael Han <<a href="mailto:Michael.Han@autodesk.com">Michael.Han@autodesk.com</a>> wrote:<br><br></div><div></div><blockquote type="cite"><div>
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">We have implemented a tool based on clang at Autodesk to help developers express their design decisions. The basic idea is the design decisions implemented
 as a set of customized GNU style attributes can serve as metadta to the fuctions, classes, etc and these metadata could be checked by clang static analyzer to enforce specific data access pattern and call graph for functions. We use this tool to help us parallelize
 some of our legacy C++ code base, for example, by enforcing a specific code is purely functinal style thus by definition is trivially thread safe.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Our implementation touches many pieces of clang as we don’t find a less intrusive way to get the attributes / metadata into clang’s type system and AST. As
 a result we have to periodically merge our code base with Clang official trunk, which sometimes is quite touch. The checker is easy to write as it is very well decoupled from the rest of the system.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I am wondering if this project would lead to an extensible annotation framework for Clang so user could encode arbitary metadata into Clang AST. That would
 be very useful and powerful for analysis code as it would involve develpers more intimately by capturing the design decisions eariler.<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Cheers<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">~Michael<o:p></o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:cfe-dev-bounces@cs.uiuc.edu">cfe-dev-bounces@cs.uiuc.edu</a> [mailto:cfe-dev-bounces@cs.uiuc.edu]
<b>On Behalf Of </b>Caitlin Sadowski<br>
<b>Sent:</b> Friday, July 01, 2011 8:58 AM<br>
<b>To:</b> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>; Delesley Hutchins; Jaeheon Yi; Jeffrey Yasskin; <a href="mailto:cormac@cs.ucsc.edu"><a href="mailto:cormac@cs.ucsc.edu">cormac@cs.ucsc.edu</a></a><br>
<b>Subject:</b> [cfe-dev] Proposal for thread safety attributes for Clang<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The following is a proposal for a project we would like to contribute to Clang. Feel free to discuss.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Cheers,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><br>
Caitlin Sadowski<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Google & University of California at Santa Cruz<o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:13.5pt"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><b><span style="font-size:14.0pt;font-family:"Arial","sans-serif";color:black">Thread Safety Attributes for Clang</span></b><span style="font-size:13.5pt"><br>
<br>
</span><b><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">Summary</span></b><span style="font-size:13.5pt"><br>
<br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">We would like to add a set of thread safety attributes to Clang. These attributes, based on a prior GCC implementation, will allow for checkable documentation of basic locking
 policies in multithreaded programs.  </span><span style="font-size:13.5pt"><br>
<br>
</span><b><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">Background</span></b><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">The synchronization policies in modern multithreaded code may be poorly documented, and incorrectly inferred by new developers. Furthermore, when these policies are improperly
 followed they often lead to bugs which are difficult to reproduce and diagnose. One strategy for avoiding concurrency bugs is formal documentation of these synchronization policies. By writing this documentation using attribute-based annotations, Clang can
 mechanically check <span style="background:white">and warn about issues that could potentially result in race conditions and deadlocks.</span></span><span style="font-size:13.5pt"><br>
<br>
</span><b><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">Example</span></b><span style="font-size:13.5pt"><br>
<br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">A code sample which demonstrates two of the proposed annotations is below. In this code sample, variables are protected by locks from the Mutex class. This class has been annotated
 to specify the API used to lock and unlock.</span><span style="font-size:13.5pt"><br>
<br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">*
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006000;background:white">GUARDED_BY</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black;background:white"> specifies a particular lock should be held when accessing
 the annotated variable. Violations of this locking policy may lead to data races.
</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black;background:white">*
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black"> </span><span style="font-size:11.0pt;font-family:"Courier New";color:#006000;background:white">ACQUIRED_AFTER</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black;background:white">
 annotations document the acquisition order between locks that can be held simultaneously by a thread, by specify the locks that need to be acquired before the annotated lock. Violations of this locking policy may lead to deadlocks.</span><span style="font-size:13.5pt"><br>
<br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> </span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">1</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#880000;background:white">#include</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#008800;background:white">"thread_annotations.h"</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> </span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">2
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#880000;background:white">#define
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006000;background:white">GUARDED_BY</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">(</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">x</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">)</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006000;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">__attribute__((</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006000;background:white">GUARDED_BY</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">(</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">x</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">)</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">))</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white"> </span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">3</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#880000;background:white">#define
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006000;background:white">ACQUIRED_AFTER</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">(</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">x</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">)</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006000;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">__attribute__((</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006000;background:white">ACQUIRED_AFTER</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">(</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">x</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">)</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">))</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> </span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">4</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> </span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">5</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">Mutex
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">mu1</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">;</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> </span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">6</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">Mutex</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> mu2</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006000;background:white">ACQUIRED_AFTER</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">(</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">mu1</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">);</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> </span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">7</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> </span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">8</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#000088;background:white">int</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> x</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006000;background:white">GUARDED_BY</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">(</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">mu1</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">);</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> </span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">9</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#000088;background:white">int</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> a
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006000;background:white">GUARDED_BY</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">(</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">mu2</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">);</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> </span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">10</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> </span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">11</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#000088;background:white">void</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> foo</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">()</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white"> 12</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">{</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">13</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">   mu2</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">.</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">Lock</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">();</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">14</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">   mu1</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">.</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">Lock</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">();</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">15</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">   </span><span style="font-size:11.0pt;font-family:"Courier New";color:#000088;background:white">if</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">(</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">x
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">></span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">2</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">)</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">16</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">     a
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">=</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> x
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">+</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">1</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">;</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">17</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">   </span><span style="font-size:11.0pt;font-family:"Courier New";color:#000088;background:white">else</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">18</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">     a
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">=</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> x
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">-</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">1</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">;</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">19</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">   mu1</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">.</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">Unlock</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">();</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">20</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">   mu2</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">.</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">Unlock</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">();</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">21</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">}</span><span style="font-size:13.5pt"><br>
<br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black;background:white">Sample compiler output:</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">ex</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">.</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">cc</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">:</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">In</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#000088;background:white">function</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#008800;background:white">'void foo()'</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">:</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">ex</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">.</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">cc</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">:</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">12</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">:</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
 warning</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">:</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#660066;background:white">Lock</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#008800;background:white">'mu1'</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#000088;background:white">is</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> acquired after
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#000088;background:white">lock</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#008800;background:white">'mu2'</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">(</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">acquired at line
</span><span style="font-size:11.0pt;font-family:"Courier New";color:#006666;background:white">14</span><span style="font-size:11.0pt;font-family:"Courier New";color:#666600;background:white">)</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white">
 but </span><span style="font-size:11.0pt;font-family:"Courier New";color:#000088;background:white">is</span><span style="font-size:11.0pt;font-family:"Courier New";color:black;background:white"> annotated otherwise</span><span style="font-size:13.5pt"><br>
<br>
</span><b><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">Previous Work</span></b><span style="font-size:13.5pt"><br>
<br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">As mentioned, thread safety annotations have been implemented in GCC. A full list of the annotations and descriptions for them can be found here:</span><span style="font-size:13.5pt"><br>
<br>
<a href="http://gcc.gnu.org/wiki/ThreadSafetyAnnotation"><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#000099">http://gcc.gnu.org/wiki/ThreadSafetyAnnotation</span></a><br>
<a href="https://docs.google.com/a/google.com/Doc?id=ddqtfwhb_0c49t6zgr"><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#000099">https://docs.google.com/a/google.com/Doc?id=ddqtfwhb_0c49t6zgr</span></a><br>
<br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">These annotations have been in active use in Google’s C++ codebase for a couple of years, so there is a large informal case study of their usefulness. The ideas behind many of
 these annotations come originally from a research paper [1].</span><span style="font-size:13.5pt"><br>
<br>
</span><b><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">Plan</span></b><span style="font-size:13.5pt"><br>
<br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">We are planning to re-implement the GCC thread safety attributes in Clang. We will submit a series of patches to the cfe-commits mailing list. Our current plan for this serie
 is as follows:</span><span style="font-size:13.5pt"><br>
<br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">1) Basic parsing and semantic checking of the attributes which do not take arguments. In other words, checking whether the attribute is applied in the appropriate context (e.g.
 to a field, with no arguments).</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">2) Basic parsing and semantic checking of the attributes which do take arguments, but without parsing or checking the arguments themselves. At this point, we will simply discard
 the tokens making up the arguments. </span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">3) Attribute argument parsing.</span><span style="font-size:13.5pt"><br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">4) Adding the thread safety analysis checks. We will teach the static analysis-based warnings layer to warn for violations of the annotations discussed on the links above.
</span><span style="font-size:13.5pt"><br>
<br>
</span><b><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">Future Projects</span></b><span style="font-size:13.5pt"><br>
<br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">Once we have this core set of thread safety annotations implemented, we have several directions for future work we would like to pursue. These include supporting additional types
 of annotations. For example, we would like to extend the system to support annotations for functions which only touch thread-local data and atomic functions which always execute as if they are not interleaved with operations of other threads. We would also
 like to build an annotation inference system; this system would enable application of the thread safety analysis to large amounts of legacy code.</span><span style="font-size:13.5pt"><br>
<br>
</span><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:black">[1] C. Flanagan and S. N. Freund. Type-based race detection for Java. In Programming Language Design and Implementation (PLDI), June 2000.</span><span style="font-size:13.5pt"><o:p></o:p></span></p>
</div>
</div>
</div>


</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>cfe-dev mailing list</span><br><span><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a></span><br><span><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a></span><br></div></blockquote></body></html>