[PATCH] D60912: MS ABI: handle inline static data member and inline variable as template static data member
Reid Kleckner via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 23 16:17:55 PDT 2019
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.
lgtm
================
Comment at: lib/CodeGen/CGDeclCXX.cpp:470-471
PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn));
- } else if (isTemplateInstantiation(D->getTemplateSpecializationKind())) {
+ } else if (isTemplateInstantiation(D->getTemplateSpecializationKind()) ||
+ getContext().GetGVALinkageForVariable(D) == GVA_DiscardableODR) {
// C++ [basic.start.init]p2:
----------------
I think this can be simplified by removing the `isTemplateInstantiation` check and then checking for GVA_DiscardableODR or GVA_StrongODR. That will handle the cases of explicit template instantiation that you have below.
It's up to you if you want to implement the simplification. The current code is correct, I don't believe it's possible to create a GVA_StrongODR global variable with a dynamic initializer without template instantiation (phew).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60912/new/
https://reviews.llvm.org/D60912
More information about the cfe-commits
mailing list