<div dir="ltr">On Tue, Aug 20, 2013 at 11:30 AM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="im">On Mon, Aug 19, 2013 at 5:51 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>></span> wrote:<br></div><div class="gmail_extra">
<div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div>class MicrosoftFunctionState : public CXXABIFunctionState {</div>

<div>public:</div><div>  MicrosoftFunctionState() : NumGuardedInitsEmitted(0), GuardGV(0) {}</div><div>  int NumGuardedInitsEmitted;</div>
<div>  llvm::GlobalVariable *GuardGV;</div><div>};</div></div><div><br></div><div>This is very suspicious.  For the Itanium ABI, to get this right, we have to track it in the AST.  (See clang::MangleNumberingContext etc.)  A testcase (which we messed up with the Itanium ABI until quite recently):</div>


<div><br></div><div><div>int foo();</div><div>inline void f() {</div><div>  if (0) {</div><div>    static int x = foo();</div><div>  }</div><div>  static int x = foo();</div><div>}</div><div>void g() { f(); }</div></div>

</div></blockquote><div><br></div></div><div>Yeah, I get the bit numbers wrong.  What I actually need to do is to number all the static local VarDecls in a DeclContext based on source order like this:</div><div><br></div>
<div>inline void f() {</div>
<div><div>  if (0) {<br></div><div>    static int x = foo(); // 1</div><div>  }</div><div>  static int x = foo(); // 2</div><div>  static int y = foo(); // 3</div><div>  static int z = foo(); // 4<br></div><div>}</div></div>

<div><br></div><div>Maybe what we should do here is ask the AST/CXXABI class to create the ManglingNumberContext, and I can provide an implementation for the Microsoft C++ ABI.  Sound good?</div></div></div></div></blockquote>
<div><br></div><div>That sounds like the right direction.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">
<div class="gmail_quote"><div><br></div><div>---</div>
<div><br></div><div>By the way, lambdas are mangled totally differently.  David knows more.  We think it's some kind of hash of the token stream that clang will probably never be able to replicate.  We may have to make up our own mangling.</div>

</div></div></div>
</blockquote></div><br></div><div class="gmail_extra">Really?  Wow.  (In the Itanium ABI, we number them in source order.)<br><br>-Eli<br></div></div>