[PATCH] Fix asserts about emitting constexpr methods twice during dllexport explicit instantiation (PR21718)

Hans Wennborg hans at chromium.org
Thu Dec 18 19:07:58 PST 2014


Richard's suggestion about having a separate function instead of HandleTopLevelDecl that would be used for updating the linkage after explicit instantiation got me thinking about how that would work if the definition had already been emitted.

To be able to change the linkage from weak to strong, it would be nice if the function was not emitted yet. This is what happens with normal implicit template instantiations today: on first use (which is typically what triggered the instantiation), they get moved into deferredDeclsToEmit, and then stay there until the end of the TU.

The only reason this doesn't work with dllexport or attribute(used) functions is that MayDeferGeneration() returns false for those. That's actually a misnomer because deferring is not a problem for them, as long as they are emitted in the end.

This patch tries to solve the problem by reorganizing the logic about deferring generation.

At least this feels a lot less hacky than the previous patch :)


http://reviews.llvm.org/D6674

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/dllexport.cpp
  test/CodeGenCXX/explicit-instantiation.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6674.17478.patch
Type: text/x-patch
Size: 7189 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141219/bfe165a3/attachment.bin>


More information about the cfe-commits mailing list