MS compatibility: always emit dllexported in-class initialized static data members (PR20140)

This makes us emit dllexported in-class initialized static data members (which
are treated as definitions in MSVC), even when they're not referenced.

It also makes their special linkage reflected in the GVA linkage instead of
getting massaged in CodeGen.

Differential Revision: http://reviews.llvm.org/D4563

llvm-svn: 213304
This commit is contained in:
Hans Wennborg
2014-07-17 20:25:23 +00:00
parent 42f79dbf02
commit 56fc62bf01
10 changed files with 71 additions and 48 deletions

View File

@@ -128,6 +128,19 @@ namespace {
return;
Builder->UpdateCompletedType(D);
// For MSVC compatibility, treat declarations of static data members with
// inline initializers as definitions.
if (Ctx->getLangOpts().MSVCCompat) {
for (Decl *Member : D->decls()) {
if (VarDecl *VD = dyn_cast<VarDecl>(Member)) {
if (Ctx->isMSStaticDataMemberInlineDefinition(VD) &&
Ctx->DeclMustBeEmitted(VD)) {
Builder->EmitGlobal(VD);
}
}
}
}
}
void HandleTagDeclRequiredDefinition(const TagDecl *D) override {