diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-04-15 01:08:06 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-04-15 01:08:06 +0000 |
commit | e07140eb3fb5b2d3df2f57cccc633a0d1e21c6f2 (patch) | |
tree | 7ae34ebf92346ca97b9df63beff0cac6f606dd98 /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 58927f1aa2e37854b5ff728eedda8ec8aff779be (diff) | |
download | bcm5719-llvm-e07140eb3fb5b2d3df2f57cccc633a0d1e21c6f2.tar.gz bcm5719-llvm-e07140eb3fb5b2d3df2f57cccc633a0d1e21c6f2.zip |
Move the logic to avoid double global emission from Sema to CodeGen
Reverts the code changes from r234675 but keeps the test case.
We were already maintaining a DenseMap of globals with dynamic
initializers anyway.
Fixes the test case from PR23234.
llvm-svn: 234961
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 014400822c3..6936539f1ca 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3865,17 +3865,6 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation, if (TSK == TSK_ExplicitInstantiationDeclaration) return; - // We may be explicitly instantiating something we've already implicitly - // instantiated. - VarDecl *InstantiatedDef = Var->getDefinition(); - if (InstantiatedDef) - InstantiatedDef->setTemplateSpecializationKind(TSK, PointOfInstantiation); - - // If we've already instantiated the definition and we're not - // re-instantiating it explicitly, we don't need to do anything. - if (InstantiatedDef && TSK != TSK_ExplicitInstantiationDefinition) - return; - // Make sure to pass the instantiated variable to the consumer at the end. struct PassToConsumerRAII { ASTConsumer &Consumer; @@ -3889,10 +3878,14 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation, } } PassToConsumerRAII(Consumer, Var); - // If we already implicitly instantiated this, just let the consumer know that - // it needs to handle an explicit instantiation now. - if (InstantiatedDef && TSK == TSK_ExplicitInstantiationDefinition) + // If we already have a definition, we're done. + if (VarDecl *Def = Var->getDefinition()) { + // We may be explicitly instantiating something we've already implicitly + // instantiated. + Def->setTemplateSpecializationKind(Var->getTemplateSpecializationKind(), + PointOfInstantiation); return; + } InstantiatingTemplate Inst(*this, PointOfInstantiation, Var); if (Inst.isInvalid()) |