diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-04-11 01:25:36 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-04-11 01:25:36 +0000 |
commit | 620d0ce55c5f8f797a292c7c5e01d1906bc148e5 (patch) | |
tree | 761cb4519e8aa6e09d36e5699eee31c6669615e2 /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 63ffa21d9026e1478fd0fe3080454aacae2da0f7 (diff) | |
download | bcm5719-llvm-620d0ce55c5f8f797a292c7c5e01d1906bc148e5.tar.gz bcm5719-llvm-620d0ce55c5f8f797a292c7c5e01d1906bc148e5.zip |
Only notify consumers about static data members of class templates once
llvm-svn: 234675
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 6936539f1ca..014400822c3 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3865,6 +3865,17 @@ 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; @@ -3878,14 +3889,10 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation, } } PassToConsumerRAII(Consumer, Var); - // 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); + // 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) return; - } InstantiatingTemplate Inst(*this, PointOfInstantiation, Var); if (Inst.isInvalid()) |