github-actions[bot] wrote: <!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning: <details> <summary> You can test this locally with the following command: </summary> ``````````bash git-clang-format --diff 6f62757e779492b288a98c7c2e27eba95a551e3b 7bbecfeae5bc40c3ead47cc4bf677eb705928812 --extensions h,cpp -- clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp clang/include/clang/AST/DeclTemplate.h clang/include/clang/Sema/Sema.h clang/lib/AST/DeclTemplate.cpp clang/lib/Sema/SemaConcept.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Sema/SemaTemplateDeductionGuide.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriterDecl.cpp clang/test/CXX/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp `````````` </details> <details> <summary> View the diff from clang-format here. </summary> ``````````diff diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 6e6e075ac9..0e1f1f8b48 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -809,7 +809,8 @@ protected: }; /// Pointer to the common data shared by all declarations of this - /// template, and a flag indicating if the template is a member specialization. + /// template, and a flag indicating if the template is a member + /// specialization. mutable llvm::PointerIntPair<CommonBase *, 1, bool> Common; /// Retrieves the "common" pointer shared by all (re-)declarations of @@ -857,9 +858,7 @@ public: /// template<> template<typename T> /// struct X<int>::Inner { /* ... */ }; /// \endcode - bool isMemberSpecialization() const { - return Common.getInt(); - } + bool isMemberSpecialization() const { return Common.getInt(); } /// Note that this member template is a specialization. void setMemberSpecialization() { @@ -2190,9 +2189,7 @@ public: } /// Note that this member template is a specialization. - void setMemberSpecialization() { - return InstantiatedFromMember.setInt(true); - } + void setMemberSpecialization() { return InstantiatedFromMember.setInt(true); } /// Retrieves the injected specialization type for this partial /// specialization. This is not the same as the type-decl-type for @@ -2947,9 +2944,7 @@ public: } /// Note that this member template is a specialization. - void setMemberSpecialization() { - return InstantiatedFromMember.setInt(true); - } + void setMemberSpecialization() { return InstantiatedFromMember.setInt(true); } SourceRange getSourceRange() const override LLVM_READONLY; diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index ac817135dc..78b2ba206e 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -11384,7 +11384,8 @@ public: CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, - SourceLocation FriendLoc, ArrayRef<TemplateParameterList *> OuterTemplateParamLists, + SourceLocation FriendLoc, + ArrayRef<TemplateParameterList *> OuterTemplateParamLists, bool IsMemberSpecialization, SkipBodyInfo *SkipBody = nullptr); /// Translates template arguments as provided by the parser @@ -11424,7 +11425,8 @@ public: DeclResult ActOnVarTemplateSpecialization( Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, - StorageClass SC, bool IsPartialSpecialization, bool IsMemberSpecialization); + StorageClass SC, bool IsPartialSpecialization, + bool IsMemberSpecialization); /// Get the specialization of the given variable template corresponding to /// the specified argument list, or a null-but-valid result if the arguments diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 1815325eee..f5020cd385 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -586,7 +586,7 @@ static bool CheckConstraintSatisfaction( ArrayRef<TemplateArgument> TemplateArgs = TemplateArgsLists.getNumSubstitutedLevels() > 0 ? TemplateArgsLists.getInnermost() - : ArrayRef<TemplateArgument> {}; + : ArrayRef<TemplateArgument>{}; Sema::InstantiatingTemplate Inst(S, TemplateIDRange.getBegin(), Sema::InstantiatingTemplate::ConstraintsCheck{}, const_cast<NamedDecl *>(Template), TemplateArgs, TemplateIDRange); @@ -908,8 +908,8 @@ bool Sema::CheckFunctionConstraints(const FunctionDecl *FD, // Figure out the to-translation-unit depth for this function declaration for // the purpose of seeing if they differ by constraints. This isn't the same as // getTemplateDepth, because it includes already instantiated parents. -static unsigned -CalculateTemplateDepthForConstraints(Sema &S, const NamedDecl *ND) { +static unsigned CalculateTemplateDepthForConstraints(Sema &S, + const NamedDecl *ND) { MultiLevelTemplateArgumentList MLTAL = S.getTemplateInstantiationArgs( ND, ND->getLexicalDeclContext(), /*Final=*/false, /*Innermost=*/std::nullopt, @@ -1061,11 +1061,11 @@ bool Sema::FriendConstraintsDependOnEnclosingTemplate(const FunctionDecl *FD) { SmallVector<const Expr *, 3> ACs; FTD->getAssociatedConstraints(ACs); - #if 0 +#if 0 unsigned OldTemplateDepth = CalculateTemplateDepthForConstraints(*this, FD); - #else +#else unsigned OldTemplateDepth = FTD->getTemplateParameters()->getDepth(); - #endif +#endif for (const Expr *Constraint : ACs) if (ConstraintExpressionDependsOnEnclosingTemplate(FD, OldTemplateDepth, Constraint)) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 1844c19f01..4dc15a4a75 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4501,10 +4501,10 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) { adjustDeclContextForDeclaratorDecl(New, Old); // Ensure the template parameters are compatible. - if (NewTemplate && - !TemplateParameterListsAreEqual(NewTemplate, NewTemplate->getTemplateParameters(), - OldTemplate, OldTemplate->getTemplateParameters(), - /*Complain=*/true, TPL_TemplateMatch)) + if (NewTemplate && !TemplateParameterListsAreEqual( + NewTemplate, NewTemplate->getTemplateParameters(), + OldTemplate, OldTemplate->getTemplateParameters(), + /*Complain=*/true, TPL_TemplateMatch)) return New->setInvalidDecl(); // C++ [class.mem]p1: diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index e5e030cf52..bb9a69907c 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -17410,7 +17410,8 @@ DeclResult Sema::ActOnTemplatedFriendTag( return CheckClassTemplate(S, TagSpec, TagUseKind::Friend, TagLoc, SS, Name, NameLoc, Attr, TemplateParams, AS_public, /*ModulePrivateLoc=*/SourceLocation(), - FriendLoc, TempParamLists.drop_back(), IsMemberSpecialization) + FriendLoc, TempParamLists.drop_back(), + IsMemberSpecialization) .get(); } else { // The "template<>" header is extraneous. diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 16e3788d7d..79cf52cb09 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -1793,7 +1793,8 @@ DeclResult Sema::CheckClassTemplate( CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, - SourceLocation FriendLoc, ArrayRef<TemplateParameterList *> OuterTemplateParamLists, + SourceLocation FriendLoc, + ArrayRef<TemplateParameterList *> OuterTemplateParamLists, bool IsMemberSpecialization, SkipBodyInfo *SkipBody) { assert(TemplateParams && TemplateParams->size() > 0 && "No template parameters"); @@ -2037,8 +2038,7 @@ DeclResult Sema::CheckClassTemplate( /*DelayTypeCreation=*/true); SetNestedNameSpecifier(*this, NewClass, SS); if (!OuterTemplateParamLists.empty()) - NewClass->setTemplateParameterListsInfo( - Context, OuterTemplateParamLists); + NewClass->setTemplateParameterListsInfo(Context, OuterTemplateParamLists); // Add alignment attributes if necessary; these attributes are checked when // the ASTContext lays out the structure. @@ -2081,26 +2081,28 @@ DeclResult Sema::CheckClassTemplate( // Ensure that the template parameter lists are compatible. Skip this check // for a friend in a dependent context: the template parameter list itself // could be dependent. - if (ShouldAddRedecl && PrevClassTemplate && !TemplateParameterListsAreEqual( - NewTemplate, TemplateParams, - PrevClassTemplate, PrevClassTemplate->getTemplateParameters(), - /*Complain=*/true, TPL_TemplateMatch)) + if (ShouldAddRedecl && PrevClassTemplate && + !TemplateParameterListsAreEqual( + NewTemplate, TemplateParams, PrevClassTemplate, + PrevClassTemplate->getTemplateParameters(), + /*Complain=*/true, TPL_TemplateMatch)) return true; // Check the template parameter list of this declaration, possibly // merging in the template parameter list from the previous class // template declaration. Skip this check for a friend in a dependent // context, because the template parameter list might be dependent. - if (ShouldAddRedecl && CheckTemplateParameterList( - TemplateParams, - PrevClassTemplate ? PrevClassTemplate->getTemplateParameters() - : nullptr, - (SS.isSet() && SemanticContext && SemanticContext->isRecord() && - SemanticContext->isDependentContext()) - ? TPC_ClassTemplateMember - : TUK == TagUseKind::Friend ? TPC_FriendClassTemplate - : TPC_ClassTemplate, - SkipBody)) + if (ShouldAddRedecl && + CheckTemplateParameterList( + TemplateParams, + PrevClassTemplate ? PrevClassTemplate->getTemplateParameters() + : nullptr, + (SS.isSet() && SemanticContext && SemanticContext->isRecord() && + SemanticContext->isDependentContext()) + ? TPC_ClassTemplateMember + : TUK == TagUseKind::Friend ? TPC_FriendClassTemplate + : TPC_ClassTemplate, + SkipBody)) Invalid = true; if (TUK == TagUseKind::Definition && (!SkipBody || !SkipBody->ShouldSkip)) @@ -3940,7 +3942,8 @@ void Sema::CheckDeductionGuideTemplate(FunctionTemplateDecl *TD) { DeclResult Sema::ActOnVarTemplateSpecialization( Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, - StorageClass SC, bool IsPartialSpecialization, bool IsMemberSpecialization) { + StorageClass SC, bool IsPartialSpecialization, + bool IsMemberSpecialization) { // D must be variable template id. assert(D.getName().getKind() == UnqualifiedIdKind::IK_TemplateId && "Variable template specialization is declared with a template id."); @@ -8261,15 +8264,12 @@ DeclResult Sema::ActOnClassTemplateSpecialization( Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template) << /*class template*/ 0 << (TUK == TagUseKind::Definition) << FixItHint::CreateRemoval(SourceRange(LAngleLoc, RAngleLoc)); - return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS, - ClassTemplate->getIdentifier(), - TemplateNameLoc, - Attr, - TemplateParams, - AS_none, /*ModulePrivateLoc=*/SourceLocation(), - /*FriendLoc*/SourceLocation(), - TemplateParameterLists.drop_back(), - isMemberSpecialization); + return CheckClassTemplate( + S, TagSpec, TUK, KWLoc, SS, ClassTemplate->getIdentifier(), + TemplateNameLoc, Attr, TemplateParams, AS_none, + /*ModulePrivateLoc=*/SourceLocation(), + /*FriendLoc*/ SourceLocation(), TemplateParameterLists.drop_back(), + isMemberSpecialization); } // Create a new class template partial specialization declaration node. diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp index 7415e1e153..10ca5d6664 100644 --- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp +++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp @@ -317,7 +317,8 @@ struct ConvertConstructorToDeductionGuideTransform { } if (NestedPattern) - OuterInstantiationArgs = SemaRef.getTemplateInstantiationArgs(/*D=*/nullptr, Template->getDeclContext()); + OuterInstantiationArgs = SemaRef.getTemplateInstantiationArgs( + /*D=*/nullptr, Template->getDeclContext()); } Sema &SemaRef; @@ -786,8 +787,7 @@ buildAssociatedConstraints(Sema &SemaRef, FunctionTemplateDecl *F, getDepthAndIndex(TP).first + AdjustDepth); FirstUndeducedParamIdx += 1; assert(InnerArgsForBuildingRC[Index].isNull()); - InnerArgsForBuildingRC[Index] = - Context.getInjectedTemplateArg(NewParam); + InnerArgsForBuildingRC[Index] = Context.getInjectedTemplateArg(NewParam); continue; } TemplateArgumentLoc Input = @@ -828,11 +828,12 @@ buildAssociatedConstraints(Sema &SemaRef, FunctionTemplateDecl *F, // NOTE: The underlying deduction guide F is instantiated -- either from an // explicitly-written deduction guide member, or from a constructor. MultiLevelTemplateArgumentList ArgsForBuildingRC = - SemaRef.getTemplateInstantiationArgs( - F, F->getLexicalDeclContext(), - /*Final=*/false, /*Innermost=*/InnerArgsForBuildingRC, - /*RelativeToPrimary=*/true, - /*ForConstraintInstantiation=*/true);; + SemaRef.getTemplateInstantiationArgs(F, F->getLexicalDeclContext(), + /*Final=*/false, + /*Innermost=*/InnerArgsForBuildingRC, + /*RelativeToPrimary=*/true, + /*ForConstraintInstantiation=*/true); + ; ArgsForBuildingRC.setKind(clang::TemplateSubstitutionKind::Rewrite); ExprResult E = SemaRef.SubstExpr(RC, ArgsForBuildingRC); diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 74698a783f..9541f07bfb 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -140,7 +140,7 @@ bool isLambdaEnclosedByTypeAliasDecl( } struct TemplateInstantiationArgumentCollecter - : DeclVisitor<TemplateInstantiationArgumentCollecter, Decl*> { + : DeclVisitor<TemplateInstantiationArgumentCollecter, Decl *> { Sema &S; MultiLevelTemplateArgumentList &Result; std::optional<ArrayRef<TemplateArgument>> Innermost; @@ -148,18 +148,14 @@ struct TemplateInstantiationArgumentCollecter bool ForConstraintInstantiation; TemplateInstantiationArgumentCollecter( - Sema &S, - MultiLevelTemplateArgumentList &Result, + Sema &S, MultiLevelTemplateArgumentList &Result, std::optional<ArrayRef<TemplateArgument>> Innermost, - bool RelativeToPrimary, - bool ForConstraintInstantiation) : - S(S), Result(Result), Innermost(Innermost), RelativeToPrimary(RelativeToPrimary), - ForConstraintInstantiation(ForConstraintInstantiation) { - } + bool RelativeToPrimary, bool ForConstraintInstantiation) + : S(S), Result(Result), Innermost(Innermost), + RelativeToPrimary(RelativeToPrimary), + ForConstraintInstantiation(ForConstraintInstantiation) {} - Decl *Done() { - return nullptr; - } + Decl *Done() { return nullptr; } Decl *ChangeDecl(const Decl *D) { RelativeToPrimary = false; @@ -170,23 +166,22 @@ struct TemplateInstantiationArgumentCollecter return ChangeDecl(Decl::castFromDeclContext(DC)); } - Decl *UseNextDecl(const Decl *D) { - return ChangeDecl(D->getDeclContext()); - } + Decl *UseNextDecl(const Decl *D) { return ChangeDecl(D->getDeclContext()); } - Decl *DontClearRelativeToPrimaryNextDecl(const Decl* D) { - return const_cast<Decl *>( - Decl::castFromDeclContext(D->getDeclContext())); + Decl *DontClearRelativeToPrimaryNextDecl(const Decl *D) { + return const_cast<Decl *>(Decl::castFromDeclContext(D->getDeclContext())); } void AddInnermostTemplateArguments(const Decl *D) { assert(Innermost); - Result.addOuterTemplateArguments(const_cast<Decl*>(D), *Innermost, /*Final=*/false); + Result.addOuterTemplateArguments(const_cast<Decl *>(D), *Innermost, + /*Final=*/false); Innermost.reset(); } - void AddOuterTemplateArguments(const Decl *D, ArrayRef<TemplateArgument> Args, bool Final) { - Result.addOuterTemplateArguments(const_cast<Decl*>(D), Args, Final); + void AddOuterTemplateArguments(const Decl *D, ArrayRef<TemplateArgument> Args, + bool Final) { + Result.addOuterTemplateArguments(const_cast<Decl *>(D), Args, Final); } Decl *VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTPD) { @@ -202,14 +197,15 @@ struct TemplateInstantiationArgumentCollecter } Decl *VisitFunctionTemplateDecl(FunctionTemplateDecl *FTD) { - assert((ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) && - "outer template not instantiated?"); + assert( + (ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) && + "outer template not instantiated?"); if (Innermost) AddInnermostTemplateArguments(FTD); else if (ForConstraintInstantiation) - AddOuterTemplateArguments( - FTD, FTD->getInjectedTemplateArgs(), /*Final=*/false); + AddOuterTemplateArguments(FTD, FTD->getInjectedTemplateArgs(), + /*Final=*/false); if (FTD->isMemberSpecialization()) return Done(); @@ -220,14 +216,15 @@ struct TemplateInstantiationArgumentCollecter } Decl *VisitVarTemplateDecl(VarTemplateDecl *VTD) { - assert((ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) && - "outer template not instantiated?"); + assert( + (ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) && + "outer template not instantiated?"); if (Innermost) AddInnermostTemplateArguments(VTD); else if (ForConstraintInstantiation) - AddOuterTemplateArguments( - VTD, VTD->getInjectedTemplateArgs(), /*Final=*/false); + AddOuterTemplateArguments(VTD, VTD->getInjectedTemplateArgs(), + /*Final=*/false); if (VTD->isMemberSpecialization()) return Done(); @@ -236,14 +233,15 @@ struct TemplateInstantiationArgumentCollecter } Decl *VisitClassTemplateDecl(ClassTemplateDecl *CTD) { - assert((ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) && - "outer template not instantiated?"); + assert( + (ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) && + "outer template not instantiated?"); if (Innermost) AddInnermostTemplateArguments(CTD); else if (ForConstraintInstantiation) - AddOuterTemplateArguments( - CTD, CTD->getInjectedTemplateArgs(), /*Final=*/false); + AddOuterTemplateArguments(CTD, CTD->getInjectedTemplateArgs(), + /*Final=*/false); if (CTD->isMemberSpecialization()) return Done(); @@ -254,20 +252,22 @@ struct TemplateInstantiationArgumentCollecter } Decl *VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *TATD) { - assert((ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) && - "outer template not instantiated?"); + assert( + (ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) && + "outer template not instantiated?"); if (Innermost) AddInnermostTemplateArguments(TATD); else if (ForConstraintInstantiation) - AddOuterTemplateArguments( - TATD, TATD->getInjectedTemplateArgs(), /*Final=*/false); + AddOuterTemplateArguments(TATD, TATD->getInjectedTemplateArgs(), + /*Final=*/false); return UseNextDecl(TATD); } Decl *VisitConceptDecl(ConceptDecl *CD) { - assert((ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) && - "outer template not instantiated?"); + assert( + (ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) && + "outer template not instantiated?"); if (Innermost) AddInnermostTemplateArguments(CD); @@ -275,12 +275,15 @@ struct TemplateInstantiationArgumentCollecter } Decl *VisitFunctionDecl(FunctionDecl *FD) { - assert(!FD->getDescribedFunctionTemplate() && "not for templated declarations"); + assert(!FD->getDescribedFunctionTemplate() && + "not for templated declarations"); if (!RelativeToPrimary) { // Add template arguments from a function template specialization. - if (const MemberSpecializationInfo *MSI = FD->getMemberSpecializationInfo(); - MSI && MSI->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) + if (const MemberSpecializationInfo *MSI = + FD->getMemberSpecializationInfo(); + MSI && + MSI->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) return Done(); // This is an implicit instantiation of an explicit specialization. We @@ -291,16 +294,16 @@ struct TemplateInstantiationArgumentCollecter } if (const TemplateArgumentList *TemplateArgs = - FD->getTemplateSpecializationArgs()) { + FD->getTemplateSpecializationArgs()) { // Add the template arguments for this specialization. if (Innermost) AddInnermostTemplateArguments(FD); else - AddOuterTemplateArguments( - FD, TemplateArgs->asArray(), /*Final=*/false); + AddOuterTemplateArguments(FD, TemplateArgs->asArray(), /*Final=*/false); if (FD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization || - (FD->getFriendObjectKind() && !FD->getPrimaryTemplate()->getFriendObjectKind())) + (FD->getFriendObjectKind() && + !FD->getPrimaryTemplate()->getFriendObjectKind())) return UseNextDecl(FD); // If this function was instantiated from a specialized member that is @@ -330,10 +333,12 @@ struct TemplateInstantiationArgumentCollecter } Decl *VisitCXXRecordDecl(CXXRecordDecl *RD) { - assert(!RD->getDescribedClassTemplate() && "not for templated declarations"); + assert(!RD->getDescribedClassTemplate() && + "not for templated declarations"); if (const MemberSpecializationInfo *MSI = RD->getMemberSpecializationInfo(); - MSI && MSI->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) + MSI && + MSI->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) return Done(); if (ForConstraintInstantiation && RD->getFriendObjectKind() && @@ -352,7 +357,7 @@ struct TemplateInstantiationArgumentCollecter if (auto TypeAlias = getEnclosingTypeAliasTemplateDecl(S); ForConstraintInstantiation && TypeAlias) { if (isLambdaEnclosedByTypeAliasDecl(RD->getLambdaCallOperator(), - TypeAlias.PrimaryTypeAliasDecl)) { + TypeAlias.PrimaryTypeAliasDecl)) { AddOuterTemplateArguments(TypeAlias.Template, TypeAlias.AssociatedTemplateArguments, /*Final=*/false); @@ -377,9 +382,10 @@ struct TemplateInstantiationArgumentCollecter return UseNextDecl(RD); } - Decl *VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *CTSD) { - // For a class-scope explicit specialization, there are no template arguments - // at this level, but there may be enclosing template arguments. + Decl * + VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *CTSD) { + // For a class-scope explicit specialization, there are no template + // arguments at this level, but there may be enclosing template arguments. if (CTSD->isClassScopeExplicitSpecialization() && !isa<ClassTemplatePartialSpecializationDecl>(CTSD)) return DontClearRelativeToPrimaryNextDecl(CTSD); @@ -390,11 +396,11 @@ struct TemplateInstantiationArgumentCollecter return Done(); if (Innermost) - AddInnermostTemplateArguments(CTSD); + AddInnermostTemplateArguments(CTSD); else - AddOuterTemplateArguments( - CTSD, CTSD->getTemplateInstantiationArgs().asArray(), - /*Final=*/false); + AddOuterTemplateArguments(CTSD, + CTSD->getTemplateInstantiationArgs().asArray(), + /*Final=*/false); if (auto *CTPSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(CTSD)) { if (CTPSD->isMemberSpecialization()) @@ -404,10 +410,12 @@ struct TemplateInstantiationArgumentCollecter // If this class template specialization was instantiated from a // specialized member that is a class template, we're done. assert(CTSD->getSpecializedTemplate() && "No class template?"); - llvm::PointerUnion<ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl *> + llvm::PointerUnion<ClassTemplateDecl *, + ClassTemplatePartialSpecializationDecl *> Specialized = CTSD->getSpecializedTemplateOrPartial(); - if (auto *CTPSD = Specialized.dyn_cast<ClassTemplatePartialSpecializationDecl *>()) { + if (auto *CTPSD = + Specialized.dyn_cast<ClassTemplatePartialSpecializationDecl *>()) { if (CTPSD->isMemberSpecialization()) return Done(); } else { @@ -418,9 +426,10 @@ struct TemplateInstantiationArgumentCollecter return DontClearRelativeToPrimaryNextDecl(CTSD); } - Decl *VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *VTSD) { - // For a class-scope explicit specialization, there are no template arguments - // at this level, but there may be enclosing template arguments. + Decl * + VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *VTSD) { + // For a class-scope explicit specialization, there are no template + // arguments at this level, but there may be enclosing template arguments. if (VTSD->isClassScopeExplicitSpecialization() && !isa<VarTemplatePartialSpecializationDecl>(VTSD)) return DontClearRelativeToPrimaryNextDecl(VTSD); @@ -431,11 +440,11 @@ struct TemplateInstantiationArgumentCollecter return Done(); if (Innermost) - AddInnermostTemplateArguments(VTSD); + AddInnermostTemplateArguments(VTSD); else - AddOuterTemplateArguments( - VTSD, VTSD->getTemplateInstantiationArgs().asArray(), - /*Final=*/false); + AddOuterTemplateArguments(VTSD, + VTSD->getTemplateInstantiationArgs().asArray(), + /*Final=*/false); if (auto *VTPSD = dyn_cast<VarTemplatePartialSpecializationDecl>(VTSD)) { if (VTPSD->isMemberSpecialization()) @@ -445,9 +454,11 @@ struct TemplateInstantiationArgumentCollecter // If this variable template specialization was instantiated from a // specialized member that is a variable template, we're done. assert(VTSD->getSpecializedTemplate() && "No variable template?"); - llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *> + llvm::PointerUnion<VarTemplateDecl *, + VarTemplatePartialSpecializationDecl *> Specialized = VTSD->getSpecializedTemplateOrPartial(); - if (auto *VTPSD = Specialized.dyn_cast<VarTemplatePartialSpecializationDecl *>()) { + if (auto *VTPSD = + Specialized.dyn_cast<VarTemplatePartialSpecializationDecl *>()) { if (VTPSD->isMemberSpecialization()) return Done(); } else { @@ -458,10 +469,10 @@ struct TemplateInstantiationArgumentCollecter return DontClearRelativeToPrimaryNextDecl(VTSD); } - Decl *VisitImplicitConceptSpecializationDecl(ImplicitConceptSpecializationDecl *ICSD) { - AddOuterTemplateArguments( - ICSD, ICSD->getTemplateArguments(), - /*Final=*/false); + Decl *VisitImplicitConceptSpecializationDecl( + ImplicitConceptSpecializationDecl *ICSD) { + AddOuterTemplateArguments(ICSD, ICSD->getTemplateArguments(), + /*Final=*/false); return UseNextDecl(ICSD); } @@ -486,8 +497,8 @@ struct TemplateInstantiationArgumentCollecter MultiLevelTemplateArgumentList Sema::getTemplateInstantiationArgs( const NamedDecl *ND, const DeclContext *DC, bool Final, - std::optional<ArrayRef<TemplateArgument>> Innermost, - bool RelativeToPrimary, bool ForConstraintInstantiation) { + std::optional<ArrayRef<TemplateArgument>> Innermost, bool RelativeToPrimary, + bool ForConstraintInstantiation) { assert((ND || DC) && "Can't find arguments for a decl if one isn't provided"); // Accumulate the set of template argument lists in this structure. MultiLevelTemplateArgumentList Result; @@ -497,8 +508,7 @@ MultiLevelTemplateArgumentList Sema::getTemplateInstantiationArgs( CurDecl = Decl::castFromDeclContext(DC); TemplateInstantiationArgumentCollecter Collecter( - *this, Result, Innermost, RelativeToPrimary, - ForConstraintInstantiation); + *this, Result, Innermost, RelativeToPrimary, ForConstraintInstantiation); do { CurDecl = Collecter.Visit(const_cast<Decl *>(CurDecl)); } while (CurDecl); @@ -1630,11 +1640,11 @@ namespace { ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, LambdaScopeInfo *LSI) { - #if 1 +#if 1 CXXMethodDecl *MD = LSI->CallOperator; // if (MD->getParentFunctionOrMethod()) { if (true) { - #if 0 +#if 0 NamedDecl *Pattern = MD; std::optional<ArrayRef<TemplateArgument>> Innermost; if (FunctionTemplateDecl *FTD = MD->getDescribedFunctionTemplate()) { @@ -1645,8 +1655,8 @@ namespace { SemaRef.getTemplateInstantiationArgs(Pattern, Pattern->getLexicalDeclContext(), /*Final=*/false, Innermost, /*RelativeToPrimary=*/true); - #endif -; +#endif + ; for (ParmVarDecl *PVD : MD->parameters()) { assert(PVD && "null in a parameter list"); if (!PVD->hasDefaultArg()) @@ -1660,13 +1670,13 @@ namespace { // that downstream diagnostics are omitted. ExprResult ErrorResult = SemaRef.CreateRecoveryExpr( UninstExpr->getBeginLoc(), UninstExpr->getEndLoc(), - { UninstExpr }, UninstExpr->getType()); + {UninstExpr}, UninstExpr->getType()); if (ErrorResult.isUsable()) PVD->setDefaultArg(ErrorResult.get()); } } } - #endif +#endif return inherited::RebuildLambdaExpr(StartLoc, EndLoc, LSI); } diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 974943e5df..0463852e28 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -20,8 +20,8 @@ #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/PrettyDeclStackTrace.h" -#include "clang/AST/TypeOrdering.h" #include "clang/AST/TypeLoc.h" +#include "clang/AST/TypeOrdering.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" #include "clang/Sema/EnterExpressionEvaluationContext.h" @@ -4686,7 +4686,8 @@ bool Sema::InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, NamedDecl *Pattern = FD; std::optional<ArrayRef<TemplateArgument>> Innermost; - if (FD->isCXXClassMember() && !isGenericLambdaCallOperatorOrStaticInvokerSpecialization(FD)) { + if (FD->isCXXClassMember() && + !isGenericLambdaCallOperatorOrStaticInvokerSpecialization(FD)) { if (FunctionTemplateDecl *FTD = FD->getPrimaryTemplate()) { Pattern = FTD->getFirstDecl(); Innermost = FD->getTemplateSpecializationArgs()->asArray(); diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 9b99a577c0..b3606129cc 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -9951,7 +9951,8 @@ void ASTReader::finishPendingActions() { auto RTD = cast<RedeclarableTemplateDecl>(D)->getCanonicalDecl(); for (auto *R = getMostRecentExistingDecl(RTD); R; R = R->getPreviousDecl()) - cast<RedeclarableTemplateDecl>(R)->Common.setPointer(RTD->Common.getPointer()); + cast<RedeclarableTemplateDecl>(R)->Common.setPointer( + RTD->Common.getPointer()); } PendingDefinitions.clear(); diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 618aa65c2e..c91f156cb5 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -2567,7 +2567,7 @@ void ASTDeclReader::VisitClassTemplatePartialSpecializationDecl( // These are read/set from/to the first declaration. if (ThisDeclID == Redecl.getFirstID()) { D->InstantiatedFromMember.setPointer( - readDeclAs<ClassTemplatePartialSpecializationDecl>()); + readDeclAs<ClassTemplatePartialSpecializationDecl>()); } } @@ -2660,7 +2660,7 @@ void ASTDeclReader::VisitVarTemplatePartialSpecializationDecl( D->TemplateParams = Params; RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D); - D->InstantiatedFromMember.setInt(Record.readInt()); + D->InstantiatedFromMember.setInt(Record.readInt()); // These are read/set from/to the first declaration. if (ThisDeclID == Redecl.getFirstID()) { `````````` </details> https://github.com/llvm/llvm-project/pull/106585 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits