aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp31
1 files changed, 4 insertions, 27 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 66ac524..6c33f92 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1256,7 +1256,8 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
const auto *VD = cast<VarDecl>(Global);
assert(VD->isFileVarDecl() && "Cannot emit local var decl as global.");
- if (VD->isThisDeclarationADefinition() != VarDecl::Definition)
+ if (VD->isThisDeclarationADefinition() != VarDecl::Definition &&
+ !Context.isMSStaticDataMemberInlineDefinition(VD))
return;
}
@@ -1592,18 +1593,6 @@ bool CodeGenModule::isTypeConstant(QualType Ty, bool ExcludeCtor) {
return true;
}
-static bool isVarDeclInlineInitializedStaticDataMember(const VarDecl *VD) {
- if (!VD->isStaticDataMember())
- return false;
- const VarDecl *InitDecl;
- const Expr *InitExpr = VD->getAnyInitializer(InitDecl);
- if (!InitExpr)
- return false;
- if (InitDecl->isThisDeclarationADefinition())
- return false;
- return true;
-}
-
/// GetOrCreateLLVMGlobal - If the specified mangled name is not in the module,
/// create and return an llvm GlobalVariable with the specified type. If there
/// is something in the module with the specified name, return it potentially
@@ -1666,9 +1655,9 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
// If required by the ABI, treat declarations of static data members with
// inline initializers as definitions.
- if (getCXXABI().isInlineInitializedStaticDataMemberLinkOnce() &&
- isVarDeclInlineInitializedStaticDataMember(D))
+ if (getContext().isMSStaticDataMemberInlineDefinition(D)) {
EmitGlobalVarDefinition(D);
+ }
// Handle XCore specific ABI requirements.
if (getTarget().getTriple().getArch() == llvm::Triple::xcore &&
@@ -2087,18 +2076,6 @@ llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageForDeclarator(
return !Context.getLangOpts().AppleKext ? llvm::Function::WeakODRLinkage
: llvm::Function::ExternalLinkage;
- // If required by the ABI, give definitions of static data members with inline
- // initializers at least linkonce_odr linkage.
- auto const VD = dyn_cast<VarDecl>(D);
- if (getCXXABI().isInlineInitializedStaticDataMemberLinkOnce() &&
- VD && isVarDeclInlineInitializedStaticDataMember(VD)) {
- if (VD->hasAttr<DLLImportAttr>())
- return llvm::GlobalValue::AvailableExternallyLinkage;
- if (VD->hasAttr<DLLExportAttr>())
- return llvm::GlobalValue::WeakODRLinkage;
- return llvm::GlobalValue::LinkOnceODRLinkage;
- }
-
// C++ doesn't have tentative definitions and thus cannot have common
// linkage.
if (!getLangOpts().CPlusPlus && isa<VarDecl>(D) &&