[PATCH] [-cxx-abi microsoft] Emit linkonce_odr definitions for declarations of static data members with inline initializers (PR17689)
Reid Kleckner
rnk at google.com
Wed Nov 20 14:12:21 PST 2013
================
Comment at: lib/CodeGen/CodeGenModule.cpp:1873
@@ +1872,3 @@
+ if (getTarget().getCXXABI().isMicrosoft() && D->isStaticDataMember() &&
+ InitExpr && !InitDecl->isThisDeclarationADefinition())
+ GV->setLinkage(llvm::GlobalVariable::LinkOnceODRLinkage);
----------------
Can you add some test cases for the other side of this?
struct S { static const int x; }; const int S::x = 1;
Is S::x selectany or strong here?
================
Comment at: lib/CodeGen/CodeGenModule.cpp:1613
@@ +1612,3 @@
+ // initializers as definitions.
+ if (getTarget().getCXXABI().isMicrosoft() && D->isStaticDataMember() &&
+ D->hasInit() && !D->isThisDeclarationADefinition())
----------------
The advice I've gotten from John is to add predicates to TargetCXXABI like isArgumentDestroyedByCallee() and use those instead of querying isMicrosoft() directly. This would be something like isStaticDataMemberLinkOnce().
http://llvm-reviews.chandlerc.com/D2233
More information about the cfe-commits
mailing list