Do not emit duplicate global initializers for template static data members inside namespaces

A quirk of AST representation leads to class template static data member
definitions being visited twice during Clang IRGen resulting in
duplicate (benign) initializers.

Discovered while investigating a possibly-related debug info bug tickled
by the duplicate emission of these members & their associated debug
info.

With thanks to Richard Smith for help investigating, understanding, and
helping with the fix.

llvm-svn: 189996
This commit is contained in:
David Blaikie
2013-09-04 21:07:37 +00:00
parent 2a749ee0b9
commit b00f360e8f
2 changed files with 34 additions and 4 deletions

View File

@@ -2761,8 +2761,13 @@ void CodeGenModule::EmitObjCIvarInitializations(ObjCImplementationDecl *D) {
/// EmitNamespace - Emit all declarations in a namespace.
void CodeGenModule::EmitNamespace(const NamespaceDecl *ND) {
for (RecordDecl::decl_iterator I = ND->decls_begin(), E = ND->decls_end();
I != E; ++I)
I != E; ++I) {
if (const VarDecl *VD = dyn_cast<VarDecl>(*I))
if (VD->getTemplateSpecializationKind() != TSK_ExplicitSpecialization &&
VD->getTemplateSpecializationKind() != TSK_Undeclared)
continue;
EmitTopLevelDecl(*I);
}
}
// EmitLinkageSpec - Emit all declarations in a linkage spec.