diff options
author | Jennifer Yu <jennifer.yu@intel.com> | 2019-04-25 17:45:45 +0000 |
---|---|---|
committer | Jennifer Yu <jennifer.yu@intel.com> | 2019-04-25 17:45:45 +0000 |
commit | c19f4f8069722f6804086d4438a0254104242c46 (patch) | |
tree | 5d74cbccb8759ef08d640847482ccb54efa0043c /clang/lib | |
parent | b0e2daf64b8167dc7729cc7486f0c94c8902e9c6 (diff) | |
download | bcm5719-llvm-c19f4f8069722f6804086d4438a0254104242c46.tar.gz bcm5719-llvm-c19f4f8069722f6804086d4438a0254104242c46.zip |
Fix bug 37903:MS ABI: handle inline static data member and inline variable as template static data member
llvm-svn: 359212
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGDeclCXX.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 15ab1638c67..c7d65f16191 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -467,7 +467,8 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, } else if (auto *IPA = D->getAttr<InitPriorityAttr>()) { OrderGlobalInits Key(IPA->getPriority(), PrioritizedCXXGlobalInits.size()); 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: // Definitions of explicitly specialized class template static data // members have ordered initialization. Other class template static data @@ -481,6 +482,11 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, // minor startup time optimization. In the MS C++ ABI, there are no guard // variables, so this COMDAT key is required for correctness. AddGlobalCtor(Fn, 65535, COMDATKey); + if (getTarget().getCXXABI().isMicrosoft() && COMDATKey) { + // In The MS C++, MS add template static data member in the linker + // drective. + addUsedGlobal(COMDATKey); + } } else if (D->hasAttr<SelectAnyAttr>()) { // SelectAny globals will be comdat-folded. Put the initializer into a // COMDAT group associated with the global, so the initializers get folded |