diff options
author | Fangrui Song <maskray@google.com> | 2018-07-30 19:24:48 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2018-07-30 19:24:48 +0000 |
commit | abdbb605f2c3cbe63cd589da230f648535dff76b (patch) | |
tree | 5f8677c5a6cdf9e4aebd71560932f399f956f7cc /lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 19e630a4739c684e5848d2f926d0beb114bbce7b (diff) |
Remove trailing space
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 292 |
1 files changed, 146 insertions, 146 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index bc2ee42400..1aa69bd35d 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -52,7 +52,7 @@ using namespace sema; /// used to determine the proper set of template instantiation arguments for /// friend function template specializations. MultiLevelTemplateArgumentList -Sema::getTemplateInstantiationArgs(NamedDecl *D, +Sema::getTemplateInstantiationArgs(NamedDecl *D, const TemplateArgumentList *Innermost, bool RelativeToPrimary, const FunctionDecl *Pattern) { @@ -61,7 +61,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, if (Innermost) Result.addOuterTemplateArguments(Innermost); - + DeclContext *Ctx = dyn_cast<DeclContext>(D); if (!Ctx) { Ctx = D->getDeclContext(); @@ -100,7 +100,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, // use empty template parameter lists for all of the outer templates // to avoid performing any substitutions. if (Ctx->isTranslationUnit()) { - if (TemplateTemplateParmDecl *TTP + if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) { for (unsigned I = 0, N = TTP->getDepth() + 1; I != N; ++I) Result.addOuterTemplateArguments(None); @@ -108,7 +108,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, } } } - + while (!Ctx->isFileContext()) { // Add template arguments from a class template instantiation. if (ClassTemplateSpecializationDecl *Spec @@ -119,8 +119,8 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, break; Result.addOuterTemplateArguments(&Spec->getTemplateInstantiationArgs()); - - // If this class template specialization was instantiated from a + + // If this class template specialization was instantiated from a // specialized member that is a class template, we're done. assert(Spec->getSpecializedTemplate() && "No class template?"); if (Spec->getSpecializedTemplate()->isMemberSpecialization()) @@ -129,11 +129,11 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, // Add template arguments from a function template specialization. else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Ctx)) { if (!RelativeToPrimary && - (Function->getTemplateSpecializationKind() == + (Function->getTemplateSpecializationKind() == TSK_ExplicitSpecialization && !Function->getClassScopeSpecializationPattern())) break; - + if (const TemplateArgumentList *TemplateArgs = Function->getTemplateSpecializationArgs()) { // Add the template arguments for this specialization. @@ -154,7 +154,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, // Add the "injected" template arguments. Result.addOuterTemplateArguments(FunTmpl->getInjectedTemplateArgs()); } - + // If this is a friend declaration and it declares an entity at // namespace scope, take arguments from its lexical parent // instead of its semantic parent, unless of course the pattern we're @@ -200,7 +200,7 @@ bool Sema::CodeSynthesisContext::isInstantiationRecord() const { case DeclaringSpecialMember: case DefiningSynthesizedFunction: return false; - + // This function should never be called when Kind's value is Memoization. case Memoization: break; @@ -413,7 +413,7 @@ bool Sema::InstantiatingTemplate::CheckInstantiationDepth( SourceRange InstantiationRange) { assert(SemaRef.NonInstantiationEntries <= SemaRef.CodeSynthesisContexts.size()); - if ((SemaRef.CodeSynthesisContexts.size() - + if ((SemaRef.CodeSynthesisContexts.size() - SemaRef.NonInstantiationEntries) <= SemaRef.getLangOpts().InstantiationDepth) return false; @@ -517,9 +517,9 @@ void Sema::PrintInstantiationStack() { FunctionTemplateDecl *FnTmpl = cast<FunctionTemplateDecl>(Active->Entity); Diags.Report(Active->PointOfInstantiation, diag::note_explicit_template_arg_substitution_here) - << FnTmpl - << getTemplateArgumentBindingsText(FnTmpl->getTemplateParameters(), - Active->TemplateArgs, + << FnTmpl + << getTemplateArgumentBindingsText(FnTmpl->getTemplateParameters(), + Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange; break; @@ -531,8 +531,8 @@ void Sema::PrintInstantiationStack() { Diags.Report(Active->PointOfInstantiation, diag::note_function_template_deduction_instantiation_here) << FnTmpl - << getTemplateArgumentBindingsText(FnTmpl->getTemplateParameters(), - Active->TemplateArgs, + << getTemplateArgumentBindingsText(FnTmpl->getTemplateParameters(), + Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange; } else { @@ -556,7 +556,7 @@ void Sema::PrintInstantiationStack() { Diags.Report(Active->PointOfInstantiation, diag::note_deduced_template_arg_substitution_here) << IsVar << IsTemplate << cast<NamedDecl>(Active->Entity) - << getTemplateArgumentBindingsText(Params, Active->TemplateArgs, + << getTemplateArgumentBindingsText(Params, Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange; } @@ -596,8 +596,8 @@ void Sema::PrintInstantiationStack() { diag::note_prior_template_arg_substitution) << isa<TemplateTemplateParmDecl>(Parm) << Name - << getTemplateArgumentBindingsText(TemplateParams, - Active->TemplateArgs, + << getTemplateArgumentBindingsText(TemplateParams, + Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange; break; @@ -614,8 +614,8 @@ void Sema::PrintInstantiationStack() { Diags.Report(Active->PointOfInstantiation, diag::note_template_default_arg_checking) - << getTemplateArgumentBindingsText(TemplateParams, - Active->TemplateArgs, + << getTemplateArgumentBindingsText(TemplateParams, + Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange; break; @@ -660,7 +660,7 @@ Optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const { Active = CodeSynthesisContexts.rbegin(), ActiveEnd = CodeSynthesisContexts.rend(); Active != ActiveEnd; - ++Active) + ++Active) { switch (Active->Kind) { case CodeSynthesisContext::TemplateInstantiation: @@ -678,7 +678,7 @@ Optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const { case CodeSynthesisContext::PriorTemplateArgumentSubstitution: case CodeSynthesisContext::DefaultTemplateArgumentChecking: // A default template argument instantiation and substitution into - // template parameters with arguments for prior parameters may or may + // template parameters with arguments for prior parameters may or may // not be a SFINAE context; look further up the stack. break; @@ -752,18 +752,18 @@ namespace { ArrayRef<UnexpandedParameterPack> Unexpanded, bool &ShouldExpand, bool &RetainExpansion, Optional<unsigned> &NumExpansions) { - return getSema().CheckParameterPacksForExpansion(EllipsisLoc, + return getSema().CheckParameterPacksForExpansion(EllipsisLoc, PatternRange, Unexpanded, - TemplateArgs, + TemplateArgs, ShouldExpand, RetainExpansion, NumExpansions); } - void ExpandingFunctionParameterPack(ParmVarDecl *Pack) { + void ExpandingFunctionParameterPack(ParmVarDecl *Pack) { SemaRef.CurrentInstantiationScope->MakeInstantiatedLocalArgPack(Pack); } - + TemplateArgument ForgetPartiallySubstitutedPack() { TemplateArgument Result; if (NamedDecl *PartialPack @@ -777,14 +777,14 @@ namespace { TemplateArgs.setArgument(Depth, Index, TemplateArgument()); } } - + return Result; } - + void RememberPartiallySubstitutedPack(TemplateArgument Arg) { if (Arg.isNull()) return; - + if (NamedDecl *PartialPack = SemaRef.CurrentInstantiationScope->getPartiallySubstitutedPack()){ MultiLevelTemplateArgumentList &TemplateArgs @@ -799,7 +799,7 @@ namespace { /// this declaration. Decl *TransformDecl(SourceLocation Loc, Decl *D); - void transformAttrs(Decl *Old, Decl *New) { + void transformAttrs(Decl *Old, Decl *New) { SemaRef.InstantiateAttrs(TemplateArgs, Old, New); } @@ -817,7 +817,7 @@ namespace { NewMD->setInstantiationOfMemberFunction(OldMD, TSK_ImplicitInstantiation); } - + SemaRef.CurrentInstantiationScope->InstantiatedLocal(Old, New); // We recreated a local declaration, but not by instantiating it. There @@ -825,7 +825,7 @@ namespace { if (auto *DC = dyn_cast<DeclContext>(Old)) SemaRef.PerformDependentDiagnostics(DC, TemplateArgs); } - + /// Transform the definition of the given declaration by /// instantiating it. Decl *TransformDefinition(SourceLocation Loc, Decl *D); @@ -833,20 +833,20 @@ namespace { /// Transform the first qualifier within a scope by instantiating the /// declaration. NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc); - + /// Rebuild the exception declaration and register the declaration /// as an instantiated local. - VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, + VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *Declarator, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name); - /// Rebuild the Objective-C exception declaration and register the + /// Rebuild the Objective-C exception declaration and register the /// declaration as an instantiated local. - VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, + VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *TSInfo, QualType T); - + /// Check for tag mismatches when instantiating an /// elaborated type. QualType RebuildElaboratedType(SourceLocation KeywordLoc, @@ -921,11 +921,11 @@ namespace { TemplateParameterList *TransformTemplateParameterList( TemplateParameterList *OrigTPL) { if (!OrigTPL || !OrigTPL->size()) return OrigTPL; - + DeclContext *Owner = OrigTPL->getParam(0)->getDeclContext(); - TemplateDeclInstantiator DeclInstantiator(getSema(), + TemplateDeclInstantiator DeclInstantiator(getSema(), /* DeclContext *Owner */ Owner, TemplateArgs); - return DeclInstantiator.SubstTemplateParams(OrigTPL); + return DeclInstantiator.SubstTemplateParams(OrigTPL); } private: ExprResult transformNonTypeTemplateParmRef(NonTypeTemplateParmDecl *parm, @@ -937,17 +937,17 @@ namespace { bool TemplateInstantiator::AlreadyTransformed(QualType T) { if (T.isNull()) return true; - + if (T->isInstantiationDependentType() || T->isVariablyModifiedType()) return false; - + getSema().MarkDeclarationsReferencedInType(Loc, T); return true; } static TemplateArgument getPackSubstitutedTemplateArgument(Sema &S, TemplateArgument Arg) { - assert(S.ArgumentPackSubstitutionIndex >= 0); + assert(S.ArgumentPackSubstitutionIndex >= 0); assert(S.ArgumentPackSubstitutionIndex < (int)Arg.pack_size()); Arg = Arg.pack_begin()[S.ArgumentPackSubstitutionIndex]; if (Arg.isPackExpansion()) @@ -970,9 +970,9 @@ Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) { return D; TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition()); - + if (TTP->isParameterPack()) { - assert(Arg.getKind() == TemplateArgument::Pack && + assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack"); Arg = getPackSubstitutedTemplateArgument(getSema(), Arg); } @@ -1000,22 +1000,22 @@ Decl *TemplateInstantiator::TransformDefinition(SourceLocation Loc, Decl *D) { } NamedDecl * -TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D, +TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc) { - // If the first part of the nested-name-specifier was a template type + // If the first part of the nested-name-specifier was a template type // parameter, instantiate that type parameter down to a tag type. if (TemplateTypeParmDecl *TTPD = dyn_cast_or_null<TemplateTypeParmDecl>(D)) { - const TemplateTypeParmType *TTP + const TemplateTypeParmType *TTP = cast<TemplateTypeParmType>(getSema().Context.getTypeDeclType(TTPD)); - + if (TTP->getDepth() < TemplateArgs.getNumLevels()) { // FIXME: This needs testing w/ member access expressions. TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getIndex()); - + if (TTP->isParameterPack()) { - assert(Arg.getKind() == TemplateArgument::Pack && + assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack"); - + if (getSema().ArgumentPackSubstitutionIndex == -1) return nullptr; @@ -1025,16 +1025,16 @@ TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D, QualType T = Arg.getAsType(); if (T.isNull()) return cast_or_null<NamedDecl>(TransformDecl(Loc, D)); - + if (const TagType *Tag = T->getAs<TagType>()) return Tag->getDecl(); - + // The resulting type is not a tag; complain. getSema().Diag(Loc, diag::err_nested_name_spec_non_tag) << T; return nullptr; } } - + return cast_or_null<NamedDecl>(TransformDecl(Loc, D)); } @@ -1051,8 +1051,8 @@ TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl, return Var; } -VarDecl *TemplateInstantiator::RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, - TypeSourceInfo *TSInfo, +VarDecl *TemplateInstantiator::RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, + TypeSourceInfo *TSInfo, QualType T) { VarDecl *Var = inherited::RebuildObjCExceptionDecl(ExceptionDecl, TSInfo, T); if (Var) @@ -1107,13 +1107,13 @@ TemplateName TemplateInstantiator::TransformTemplateName( if (!TemplateArgs.hasTemplateArgument(TTP->getDepth(), TTP->getPosition())) return Name; - + TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition()); - + if (TTP->isParameterPack()) { - assert(Arg.getKind() == TemplateArgument::Pack && + assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack"); - + if (getSema().ArgumentPackSubstitutionIndex == -1) { // We have the template argument pack to substitute, but we're not // actually expanding the enclosing pack expansion yet. So, just @@ -1123,7 +1123,7 @@ TemplateName TemplateInstantiator::TransformTemplateName( Arg = getPackSubstitutedTemplateArgument(getSema(), Arg); } - + TemplateName Template = Arg.getAsTemplate().getNameToSubstitute(); assert(!Template.isNull() && "Null template template argument"); assert(!Template.getAsQualifiedTemplateName() && @@ -1133,12 +1133,12 @@ TemplateName TemplateInstantiator::TransformTemplateName( return Template; } } - + if (SubstTemplateTemplateParmPackStorage *SubstPack = Name.getAsSubstTemplateTemplateParmPack()) { if (getSema().ArgumentPackSubstitutionIndex == -1) return Name; - + TemplateArgument Arg = SubstPack->getArgumentPack(); Arg = getPackSubstitutedTemplateArgument(getSema(), Arg); return Arg.getAsTemplate().getNameToSubstitute(); @@ -1149,7 +1149,7 @@ TemplateName TemplateInstantiator::TransformTemplateName( AllowInjectedClassName); } -ExprResult +ExprResult TemplateInstantiator::TransformPredefinedExpr(PredefinedExpr *E) { if (!E->isTypeDependent()) return E; @@ -1187,15 +1187,15 @@ TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E, } if (NTTP->isParameterPack()) { - assert(Arg.getKind() == TemplateArgument::Pack && + assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack"); - + if (getSema().ArgumentPackSubstitutionIndex == -1) { // We have an argument pack, but we can't select a particular argument // out of it yet. Therefore, we'll build an expression to hold on to that // argument pack. QualType TargetType = SemaRef.SubstType(NTTP->getType(), TemplateArgs, - E->getLocation(), + E->getLocation(), NTTP->getDeclName()); if (TargetType.isNull()) return ExprError(); @@ -1205,7 +1205,7 @@ TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E, TargetType->isReferenceType() ? VK_LValue : VK_RValue, NTTP, E->getLocation(), Arg); } - + Arg = getPackSubstitutedTemplateArgument(getSema(), Arg); } @@ -1260,12 +1260,12 @@ ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef( // Propagate NULL template argument. VD = nullptr; } - + // Derive the type we want the substituted decl to have. This had // better be non-dependent, or these checks will have serious problems. if (parm->isExpandedParameterPack()) { type = parm->getExpansionType(SemaRef.ArgumentPackSubstitutionIndex); - } else if (parm->isParameterPack() && + } else if (parm->isParameterPack() && isa<PackExpansionType>(parm->getType())) { type = SemaRef.SubstType( cast<PackExpansionType>(parm->getType())->getPattern(), @@ -1292,8 +1292,8 @@ ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef( return new (SemaRef.Context) SubstNonTypeTemplateParmExpr( type, resultExpr->getValueKind(), loc, parm, resultExpr); } - -ExprResult + +ExprResult TemplateInstantiator::TransformSubstNonTypeTemplateParmPackExpr( SubstNonTypeTemplateParmPackExpr *E) { if (getSema().ArgumentPackSubstitutionIndex == -1) { @@ -1387,7 +1387,7 @@ TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) { if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) { if (NTTP->getDepth() < TemplateArgs.getNumLevels()) return TransformTemplateParmRefExpr(E, NTTP); - + // We have a non-type template parameter that isn't fully substituted; // FindInstantiatedDecl will find it in the local instantiation scope. } @@ -1406,7 +1406,7 @@ ExprResult TemplateInstantiator::TransformCXXDefaultArgExpr( getDescribedFunctionTemplate() && "Default arg expressions are never formed in dependent cases."); return SemaRef.BuildCXXDefaultArgExpr(E->getUsedLocation(), - cast<FunctionDecl>(E->getParam()->getDeclContext()), + cast<FunctionDecl>(E->getParam()->getDeclContext()), E->getParam()); } @@ -1451,11 +1451,11 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB, } TemplateArgument Arg = TemplateArgs(T->getDepth(), T->getIndex()); - + if (T->isParameterPack()) { - assert(Arg.getKind() == TemplateArgument::Pack && + assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack"); - + if (getSema().ArgumentPackSubstitutionIndex == -1) { // We have the template argument pack, but we're not expanding the // enclosing pack expansion yet. Just save the template argument @@ -1467,10 +1467,10 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB, NewTL.setNameLoc(TL.getNameLoc()); return Result; } - + Arg = getPackSubstitutedTemplateArgument(getSema(), Arg); } - + assert(Arg.getKind() == TemplateArgument::Type && "Template argument kind mismatch"); @@ -1502,7 +1502,7 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB, return Result; } -QualType +QualType TemplateInstantiator::TransformSubstTemplateTypeParmPackType( TypeLocBuilder &TLB, SubstTemplateTypeParmPackTypeLoc TL) { @@ -1565,8 +1565,8 @@ TypeSourceInfo *Sema::SubstType(TypeSourceInfo *T, assert(!CodeSynthesisContexts.empty() && "Cannot perform an instantiation without some context on the " "instantiation stack"); - - if (!T->getType()->isInstantiationDependentType() && + + if (!T->getType()->isInstantiationDependentType() && !T->getType()->isVariablyModifiedType()) return T; @@ -1582,11 +1582,11 @@ TypeSourceInfo *Sema::SubstType(TypeLoc TL, assert(!CodeSynthesisContexts.empty() && "Cannot perform an instantiation without some context on the " "instantiation stack"); - + if (TL.getType().isNull()) return nullptr; - if (!TL.getType()->isInstantiationDependentType() && + if (!TL.getType()->isInstantiationDependentType() && !TL.getType()->isVariablyModifiedType()) { // FIXME: Make a copy of the TypeLoc data here, so that we can // return a new TypeSourceInfo. Inefficient! @@ -1716,7 +1716,7 @@ void Sema::SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, UpdateExceptionSpec(New, ESI); } -ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, +ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, Optional<unsigned> NumExpansions, @@ -1727,9 +1727,9 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, TypeLoc OldTL = OldDI->getTypeLoc(); if (PackExpansionTypeLoc ExpansionTL = OldTL.getAs<PackExpansionTypeLoc>()) { - // We have a function parameter pack. Substitute into the pattern of the + // We have a function parameter pack. Substitute into the pattern of the // expansion. - NewDI = SubstType(ExpansionTL.getPatternLoc(), TemplateArgs, + NewDI = SubstType(ExpansionTL.getPatternLoc(), TemplateArgs, OldParm->getLocation(), OldParm->getDeclName()); if (!NewDI) return nullptr; @@ -1745,16 +1745,16 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, // itself is not a pack expansion type), so complain. This can occur when // the substitution goes through an alias template that "loses" the // pack expansion. - Diag(OldParm->getLocation(), + Diag(OldParm->getLocation(), diag::err_function_parameter_pack_without_parameter_packs) << NewDI->getType(); return nullptr; - } + } } else { - NewDI = SubstType(OldDI, TemplateArgs, OldParm->getLocation(), + NewDI = SubstType(OldDI, TemplateArgs, OldParm->getLocation(), OldParm->getDeclName()); } - + if (!NewDI) return nullptr; @@ -1801,15 +1801,15 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, } NewParm->setHasInheritedDefaultArg(OldParm->hasInheritedDefaultArg()); - + if (OldParm->isParameterPack() && !NewParm->isParameterPack()) { // Add the new parameter to the instantiated parameter pack. CurrentInstantiationScope->InstantiatedLocalPackArg(OldParm, NewParm); } else { // Introduce an Old -> New mapping - CurrentInstantiationScope->InstantiatedLocal(OldParm, NewParm); + CurrentInstantiationScope->InstantiatedLocal(OldParm, NewParm); } - + // FIXME: OldParm may come from a FunctionProtoType, in which case CurContext // can be anything, is this right ? NewParm->setDeclContext(CurContext); @@ -1819,7 +1819,7 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, InstantiateAttrs(TemplateArgs, OldParm, NewParm); - return NewParm; + return NewParm; } /// Substitute the given template arguments into the given set of @@ -1835,8 +1835,8 @@ bool Sema::SubstParmTypes( assert(!CodeSynthesisContexts.empty() && "Cannot perform an instantiation without some context on the " "instantiation stack"); - - TemplateInstantiator Instantiator(*this, TemplateArgs, Loc, + + TemplateInstantiator Instantiator(*this, TemplateArgs, Loc, DeclarationName()); return Instantiator.TransformFunctionTypeParams( Loc, Params, nullptr, ExtParamInfos, ParamTypes, OutParams, ParamInfos); @@ -1875,21 +1875,21 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation, bool ShouldExpand = false; bool RetainExpansion = false; Optional<unsigned> NumExpansions; - if (CheckParameterPacksForExpansion(Base.getEllipsisLoc(), + if (CheckParameterPacksForExpansion(Base.getEllipsisLoc(), Base.getSourceRange(), Unexpanded, - TemplateArgs, ShouldExpand, + TemplateArgs, ShouldExpand, RetainExpansion, NumExpansions)) { Invalid = true; continue; } - + // If we should expand this pack expansion now, do so. if (ShouldExpand) { for (unsigned I = 0; I != *NumExpansions; ++I) { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, I); - + TypeSourceInfo *BaseTypeLoc = SubstType(Base.getTypeSourceInfo(), TemplateArgs, Base.getSourceRange().getBegin(), @@ -1898,7 +1898,7 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation, Invalid = true; continue; } - + if (CXXBaseSpecifier *InstantiatedBase = CheckBaseSpecifier(Instantiation, Base.getSourceRange(), @@ -1910,10 +1910,10 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation, else Invalid = true; } - + continue; } - + // The resulting base specifier will (still) be a pack expansion. EllipsisLoc = Base.getEllipsisLoc(); Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, -1); @@ -1927,7 +1927,7 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation, Base.getSourceRange().getBegin(), DeclarationName()); } - + if (!BaseTypeLoc) { Invalid = true; continue; @@ -1999,11 +1999,11 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation, Pattern = PatternDef; // Record the point of instantiation. - if (MemberSpecializationInfo *MSInfo + if (MemberSpecializationInfo *MSInfo = Instantiation->getMemberSpecializationInfo()) { MSInfo->setTemplateSpecializationKind(TSK); MSInfo->setPointOfInstantiation(PointOfInstantiation); - } else if (ClassTemplateSpecializationDecl *Spec + } else if (ClassTemplateSpecializationDecl *Spec = dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) { Spec->setTemplateSpecializationKind(TSK); Spec->setPointOfInstantiation(PointOfInstantiation); @@ -2563,15 +2563,15 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, if (auto *Function = dyn_cast<FunctionDecl>(D)) { if (FunctionDecl *Pattern = Function->getInstantiatedFromMemberFunction()) { - MemberSpecializationInfo *MSInfo + MemberSpecializationInfo *MSInfo = Function->getMemberSpecializationInfo(); assert(MSInfo && "No member specialization information?"); if (MSInfo->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) continue; - - if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK, - Function, + + if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK, + Function, MSInfo->getTemplateSpecializationKind(), MSInfo->getPointOfInstantiation(), SuppressNew) || @@ -2610,31 +2610,31 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, if (MSInfo->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) continue; - - if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK, - Var, + + if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK, + Var, MSInfo->getTemplateSpecializationKind(), MSInfo->getPointOfInstantiation(), SuppressNew) || SuppressNew) continue; - + if (TSK == TSK_ExplicitInstantiationDefinition) { // C++0x [temp.explicit]p8: // An explicit instantiation definition that names a class template - // specialization explicitly instantiates the class template - // specialization and is only an explicit instantiation definition - // of members whose definition is visible at the point of + // specialization explicitly instantiates the class template + // specialization and is only an explicit instantiation definition + // of members whose definition is visible at the point of // instantiation. if (!Var->getInstantiatedFromStaticDataMember()->getDefinition()) continue; - + Var->setTemplateSpecializationKind(TSK, PointOfInstantiation); InstantiateVariableDefinition(PointOfInstantiation, Var); } else { Var->setTemplateSpecializationKind(TSK, PointOfInstantiation); } - } + } } else if (auto *Record = dyn_cast<CXXRecordDecl>(D)) { // Always skip the injected-class-name, along with any // redeclarations of nested classes, since both would cause us @@ -2644,10 +2644,10 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, if (Record->isInjectedClassName() || Record->getPreviousDecl() || Record->isLambda()) continue; - + MemberSpecializationInfo *MSInfo = Record->getMemberSpecializationInfo(); assert(MSInfo && "No member specialization information?"); - + if (MSInfo->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) continue; @@ -2660,33 +2660,33 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, continue; } - if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK, - Record, + if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK, + Record, MSInfo->getTemplateSpecializationKind(), MSInfo->getPointOfInstantiation(), SuppressNew) || SuppressNew) continue; - + CXXRecordDecl *Pattern = Record->getInstantiatedFromMemberClass(); assert(Pattern && "Missing instantiated-from-template information"); - + if (!Record->getDefinition()) { if (!Pattern->getDefinition()) { // C++0x [temp.explicit]p8: // An explicit instantiation definition that names a class template - // specialization explicitly instantiates the class template - // specialization and is only an explicit instantiation definition - // of members whose definition is visible at the point of + // specialization explicitly instantiates the class template + // specialization and is only an explicit instantiation definition + // of members whose definition is visible at the point of // instantiation. if (TSK == TSK_ExplicitInstantiationDeclaration) { MSInfo->setTemplateSpecializationKind(TSK); MSInfo->setPointOfInstantiation(PointOfInstantiation); } - + continue; } - + InstantiateClass(PointOfInstantiation, Record, Pattern, TemplateArgs, TSK); @@ -2698,10 +2698,10 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, MarkVTableUsed(PointOfInstantiation, Record, true); } } - + Pattern = cast_or_null<CXXRecordDecl>(Record->getDefinition()); if (Pattern) - InstantiateClassMembers(PointOfInstantiation, Pattern, TemplateArgs, + InstantiateClassMembers(PointOfInstantiation, Pattern, TemplateArgs, TSK); } else if (auto *Enum = dyn_cast<EnumDecl>(D)) { MemberSpecializationInfo *MSInfo = Enum->getMemberSpecializationInfo(); @@ -2816,10 +2816,10 @@ bool Sema::SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall, NestedNameSpecifierLoc Sema::SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, - const MultiLevelTemplateArgumentList &TemplateArgs) { + const MultiLevelTemplateArgumentList &TemplateArgs) { if (!NNS) return NestedNameSpecifierLoc(); - + TemplateInstantiator Instantiator(*this, TemplateArgs, NNS.getBeginLoc(), DeclarationName()); return Instantiator.TransformNestedNameSpecifierLoc(NNS); @@ -2850,7 +2850,7 @@ bool Sema::Subst(const TemplateArgumentLoc *Args, unsigned NumArgs, const MultiLevelTemplateArgumentList &TemplateArgs) { TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(), DeclarationName()); - + return Instantiator.TransformTemplateArguments(Args, NumArgs, Result); } @@ -2884,7 +2884,7 @@ LocalInstantiationScope::findInstantiationOf(const Decl *D) { LocalDeclsMap::iterator Found = Current->LocalDecls.find(CheckD); if (Found != Current->LocalDecls.end()) return &Found->second; - + // If this is a tag declaration, it's possible that we need to look for // a previous declaration. if (const TagDecl *Tag = dyn_cast<TagDecl>(CheckD)) @@ -2892,8 +2892,8 @@ LocalInstantiationScope::findInstantiationOf(const Decl *D) { else CheckD = nullptr; } while (CheckD); - - // If we aren't combined with our outer scope, we're done. + + // If we aren't combined with our outer scope, we're done. if (!Current->CombineWithOuterScope) break; } @@ -2965,12 +2965,12 @@ void LocalInstantiationScope::MakeInstantiatedLocalArgPack(const Decl *D) { ArgumentPacks.push_back(Pack); } -void LocalInstantiationScope::SetPartiallySubstitutedPack(NamedDecl *Pack, +void LocalInstantiationScope::SetPartiallySubstitutedPack(NamedDecl *Pack, const TemplateArgument *ExplicitArgs, unsigned NumExplicitArgs) { assert((!PartiallySubstitutedPack || PartiallySubstitutedPack == Pack) && "Already have a partially-substituted pack"); - assert((!PartiallySubstitutedPack + assert((!PartiallySubstitutedPack || NumArgsInPartiallySubstitutedPack == NumExplicitArgs) && "Wrong number of arguments in partially-substituted pack"); PartiallySubstitutedPack = Pack; @@ -2985,15 +2985,15 @@ NamedDecl *LocalInstantiationScope::getPartiallySubstitutedPack( *ExplicitArgs = nullptr; if (NumExplicitArgs) *NumExplicitArgs = 0; - - for (const LocalInstantiationScope *Current = this; Current; + + for (const LocalInstantiationScope *Current = this; Current; Current = Current->Outer) { if (Current->PartiallySubstitutedPack) { if (ExplicitArgs) *ExplicitArgs = Current->ArgsInPartiallySubstitutedPack; if (NumExplicitArgs) *NumExplicitArgs = Current->NumArgsInPartiallySubstitutedPack; - + return Current->PartiallySubstitutedPack; } |