[PATCH] D60912: MS ABI: handle inline static data member and inline variable as template static data member

Jennifer Yu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 25 10:47:50 PDT 2019

jyu2 marked an inline comment as done.
jyu2 added inline comments.

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:
rnk wrote:
> 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).
Thanks Reid!  I also think GVA_StrongODR which is set for template instantiation, but I am not too sure about it.  Since we already handle template by calling isTemplateInstantiation, and add GVA_DiscardableODR.  I'd like to with this.  If we see other problem.  We can always add it up.

Thank you so much for your review.



More information about the cfe-commits mailing list