summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-09-04 21:07:37 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-09-04 21:07:37 +0000
commitb00f360e8fc5a6171c71861a2ffca29b0400a5c0 (patch)
tree90a9aee614f88d03b4ab291f0eec6d4e3b1bced5 /clang/lib/CodeGen/CodeGenModule.cpp
parent2a749ee0b9ac2f70dd88429444aa9b3362adea75 (diff)
downloadbcm5719-llvm-b00f360e8fc5a6171c71861a2ffca29b0400a5c0.tar.gz
bcm5719-llvm-b00f360e8fc5a6171c71861a2ffca29b0400a5c0.zip
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 3b28d9d07fb..6c126718431 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -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.
OpenPOWER on IntegriCloud