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.




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60912/new/

https://reviews.llvm.org/D60912



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to