On Fri, Apr 22, 2016 at 12:59 PM, Reid Kleckner via cfe-commits < cfe-commits@lists.llvm.org> wrote:
> On Fri, Apr 22, 2016 at 12:29 PM, Richard Smith <rich...@metafoo.co.uk> > wrote: > >> On Fri, Apr 22, 2016 at 11:46 AM, Reid Kleckner via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: rnk >>> Date: Fri Apr 22 13:46:33 2016 >>> New Revision: 267186 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=267186&view=rev >>> Log: >>> Fix a bug involving deferred decl emission and PCH >>> >>> For various reasons, involving dllexport and class linkage compuations, >>> we have to wait until after the semicolon after a class declaration to >>> emit inline methods. These are "deferred" decls. Before this change, >>> finishing the tag decl would trigger us to deserialize some PCH so that >>> we could make a "pretty" IR-level type. Deserializing the PCH triggered >>> calls to HandleTopLevelDecl, which, when done, checked the deferred decl >>> list, and emitted some dllexported decls that weren't ready. >>> >>> Avoid this re-entrancy. Deferred decls should not get emitted when a tag >>> is finished, they should only be emitted after a real top level decl in >>> the main file. >>> >> >> 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? >> > > 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. > > I can't think of any ways to create a C++ tag definition in a way that > doesn't create a top level decl. > 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.) Could we trigger processing of any remaining deferred declarations in HandleTranslationUnit?
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits