<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 22, 2016 at 12:59 PM, Reid Kleckner via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><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"><span class="">On Fri, Apr 22, 2016 at 12:29 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><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"><span>On Fri, Apr 22, 2016 at 11:46 AM, Reid Kleckner via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rnk<br>
Date: Fri Apr 22 13:46:33 2016<br>
New Revision: 267186<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=267186&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=267186&view=rev</a><br>
Log:<br>
Fix a bug involving deferred decl emission and PCH<br>
<br>
For various reasons, involving dllexport and class linkage compuations,<br>
we have to wait until after the semicolon after a class declaration to<br>
emit inline methods. These are "deferred" decls. Before this change,<br>
finishing the tag decl would trigger us to deserialize some PCH so that<br>
we could make a "pretty" IR-level type. Deserializing the PCH triggered<br>
calls to HandleTopLevelDecl, which, when done, checked the deferred decl<br>
list, and emitted some dllexported decls that weren't ready.<br>
<br>
Avoid this re-entrancy. Deferred decls should not get emitted when a tag<br>
is finished, they should only be emitted after a real top level decl in<br>
the main file.<br></blockquote><div><br></div></span><div>What if there is no subsequent top-level decl after such a call? It seems like the deferred decls won't be emitted at all in that case. Is that acceptable?</div></div></div></div></blockquote><div><br></div></span><div>I think what happens is that we finish the tag declaration, and then call HandleTopLevelDecl on it directly, and that is supposed to flush the deferred methods.<br></div><div><br></div><div>I can't think of any ways to create a C++ tag definition in a way that doesn't create a top level decl.</div></div></div></div></blockquote><div><br></div><div>This seems like a fragile thing to rely on. What about template instantiation performed at end of TU? (I /think/ that case is currently fine because all the kinds of template we instantiate ultimately do result in a call to HandleTopLevelDecl or some other ASTConsumer callback, but I don't really like relying on that.)</div><div><br></div><div>Could we trigger processing of any remaining deferred declarations in HandleTranslationUnit?<br></div></div></div></div>