On Oct 25, 2009, at 3:18 PM, Daniel Dunbar wrote: > Hi Doug, > > On Wed, Oct 14, 2009 at 2:29 PM, Douglas Gregor <[email protected]> > wrote: >> Author: dgregor >> Date: Wed Oct 14 16:29:40 2009 >> New Revision: 84140 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=84140&view=rev >> Log: >> Give explicit and implicit instantiations of static data members of >> class templates the proper linkage. >> >> Daniel, please look over the CodeGenModule bits. > > Comments below. > >> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) >> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Oct 14 16:29:40 2009 >> @@ -541,7 +541,12 @@ >> } >> } >> >> - return VD->getStorageClass() == VarDecl::Static; >> + // Static data may be deferred, but out-of-line static data >> members >> + // cannot be. >> + // FIXME: What if the initializer has side effects? > > For C++ we shouldn't be deferring anything that could have side > effects. Can you fix or file this FIXME?
Filed at http://llvm.org/bugs/show_bug.cgi?id=5308 >> + return VD->isInAnonymousNamespace() || >> + (VD->getStorageClass() == VarDecl::Static && >> + !(VD->isStaticDataMember() && VD->isOutOfLine())); >> } > >> +static CodeGenModule::GVALinkage >> +GetLinkageForVariable(ASTContext &Context, const VarDecl *VD) { >> + // Everything located semantically within an anonymous namespace >> is >> + // always internal. >> + if (VD->isInAnonymousNamespace()) >> + return CodeGenModule::GVA_Internal; >> + >> + // Handle linkage for static data members. >> + if (VD->isStaticDataMember()) { >> + switch (VD->getTemplateSpecializationKind()) { >> + case TSK_Undeclared: >> + case TSK_ExplicitSpecialization: >> + case TSK_ExplicitInstantiationDefinition: >> + return CodeGenModule::GVA_StrongExternal; >> + >> + case TSK_ExplicitInstantiationDeclaration: >> + assert(false && "Variable should not be instantiated"); >> + // Fall through to treat this like any other instantiation. > > I think we are moving towards using llvm_unreachable for these. I didn't even realize that existed :) Thanks! - Doug _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
