From: Richard Smith Date: Sat, 22 Mar 2014 01:43:32 +0000 (+0000) Subject: Refactor: move loading pending instantiations from chained PCHs to a more appropriate... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5370eb183b7009513a1e17aa9638865cf44daead;p=clang Refactor: move loading pending instantiations from chained PCHs to a more appropriate place, so that we only ask the external source once. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204535 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index aa223bacab..3612bb962c 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -620,7 +620,15 @@ void Sema::ActOnEndOfTranslationUnit() { // so it will find some names that are not required to be found. This is // valid, but we could do better by diagnosing if an instantiation uses a // name that was not visible at its first point of instantiation. + if (ExternalSource) { + // Load pending instantiations from the external source. + SmallVector Pending; + ExternalSource->ReadPendingInstantiations(Pending); + PendingInstantiations.insert(PendingInstantiations.begin(), + Pending.begin(), Pending.end()); + } PerformPendingInstantiations(); + CheckDelayedMemberExceptionSpecs(); } diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 029f9a2dcb..376f6f79f4 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3439,6 +3439,8 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, PerformDependentDiagnostics(PatternDecl, TemplateArgs); + // FIXME: Notify the ASTMutationListener that we did this. + savedContext.pop(); } @@ -4592,14 +4594,6 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, /// \brief Performs template instantiation for all implicit template /// instantiations we have seen until this point. void Sema::PerformPendingInstantiations(bool LocalOnly) { - // Load pending instantiations from the external source. - if (!LocalOnly && ExternalSource) { - SmallVector Pending; - ExternalSource->ReadPendingInstantiations(Pending); - PendingInstantiations.insert(PendingInstantiations.begin(), - Pending.begin(), Pending.end()); - } - while (!PendingLocalImplicitInstantiations.empty() || (!LocalOnly && !PendingInstantiations.empty())) { PendingImplicitInstantiation Inst; diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map index 574eba4759..9f0fc0a29d 100644 --- a/test/Modules/Inputs/module.map +++ b/test/Modules/Inputs/module.map @@ -15,6 +15,9 @@ module diamond_bottom { export * } module irgen { header "irgen.h" } +module cxx_irgen_top { header "cxx-irgen-top.h" } +module cxx_irgen_left { header "cxx-irgen-left.h" } +module cxx_irgen_right { header "cxx-irgen-right.h" } module lookup_left_objc { header "lookup_left.h" } module lookup_right_objc { header "lookup_right.h" } module lookup_left_cxx { header "lookup_left.hpp" }