[clang] [clang][NFC] Un-constify `MultiLevelTemplateArgumentList` (PR #104687)

via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 17 17:06:39 PDT 2024


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 27d37ee4d067f42e9a46a0871d3cb961323e5c85 919da31d73a408f16e1c855cb658359b73ad1d28 --extensions cpp,h -- clang/include/clang/AST/Decl.h clang/include/clang/AST/DeclTemplate.h clang/include/clang/AST/ExprConcepts.h clang/include/clang/AST/NestedNameSpecifier.h clang/include/clang/AST/Type.h clang/include/clang/Sema/Sema.h clang/include/clang/Sema/SemaConcept.h clang/include/clang/Sema/Template.h clang/lib/AST/Decl.cpp clang/lib/AST/DeclTemplate.cpp clang/lib/AST/Type.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaCodeComplete.cpp clang/lib/Sema/SemaConcept.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaInit.cpp clang/lib/Sema/SemaLookup.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/unittests/AST/SourceLocationTest.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 2ec49427e3..c6f3d59cda 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -290,9 +290,7 @@ public:
   }
 
   /// Retrieve a pointer to the template argument list.
-  TemplateArgument *data() {
-    return getTrailingObjects<TemplateArgument>();
-  }
+  TemplateArgument *data() { return getTrailingObjects<TemplateArgument>(); }
 };
 
 void *allocateDefaultArgStorageChain(const ASTContext &C);
@@ -1892,11 +1890,10 @@ public:
 
   /// Retrieve the template arguments of the class template
   /// specialization.
-  TemplateArgumentList &getTemplateArgs() {
-    return *TemplateArgs;
-  }
+  TemplateArgumentList &getTemplateArgs() { return *TemplateArgs; }
   const TemplateArgumentList &getTemplateArgs() const {
-    return const_cast<ClassTemplateSpecializationDecl *>(this)->getTemplateArgs();
+    return const_cast<ClassTemplateSpecializationDecl *>(this)
+        ->getTemplateArgs();
   }
 
   void setTemplateArgs(TemplateArgumentList *Args) {
@@ -1998,7 +1995,8 @@ public:
     return getTemplateArgs();
   }
   const TemplateArgumentList &getTemplateInstantiationArgs() const {
-    return const_cast<ClassTemplateSpecializationDecl *>(this)->getTemplateInstantiationArgs();
+    return const_cast<ClassTemplateSpecializationDecl *>(this)
+        ->getTemplateInstantiationArgs();
   }
 
   /// Note that this class template specialization is actually an
@@ -3231,11 +3229,12 @@ public:
                      unsigned NumTemplateArgs);
 
   MutableArrayRef<TemplateArgument> getTemplateArguments() {
-    return MutableArrayRef<TemplateArgument>(getTrailingObjects<TemplateArgument>(),
-                                      NumTemplateArgs);
+    return MutableArrayRef<TemplateArgument>(
+        getTrailingObjects<TemplateArgument>(), NumTemplateArgs);
   }
   ArrayRef<TemplateArgument> getTemplateArguments() const {
-    return const_cast<ImplicitConceptSpecializationDecl *>(this)->getTemplateArguments();
+    return const_cast<ImplicitConceptSpecializationDecl *>(this)
+        ->getTemplateArguments();
   }
   void setTemplateArguments(ArrayRef<TemplateArgument> Converted);
 
diff --git a/clang/include/clang/AST/ExprConcepts.h b/clang/include/clang/AST/ExprConcepts.h
index 76ab0bbbcc..1c9889e102 100644
--- a/clang/include/clang/AST/ExprConcepts.h
+++ b/clang/include/clang/AST/ExprConcepts.h
@@ -82,7 +82,8 @@ public:
     return SpecDecl->getTemplateArguments();
   }
   ArrayRef<TemplateArgument> getTemplateArguments() const {
-    return const_cast<ConceptSpecializationExpr *>(this)->getTemplateArguments();
+    return const_cast<ConceptSpecializationExpr *>(this)
+        ->getTemplateArguments();
   }
 
   ConceptReference *getConceptReference() const { return ConceptRef; }
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index e46af5797a..2956d6259e 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11859,7 +11859,7 @@ public:
     bool isInvalid() const { return !ND && !DC; }
 
     NamedDecl *getDecl() { return ND; }
-    const NamedDecl *getDecl() const { 
+    const NamedDecl *getDecl() const {
       return const_cast<TemplateCompareNewDeclInfo *>(this)->getDecl();
     }
 
@@ -13682,8 +13682,7 @@ public:
   /// Usually this should not be used, and template argument deduction should be
   /// used in its place.
   FunctionDecl *InstantiateFunctionDeclaration(
-      FunctionTemplateDecl *FTD, TemplateArgumentList *Args,
-      SourceLocation Loc,
+      FunctionTemplateDecl *FTD, TemplateArgumentList *Args, SourceLocation Loc,
       CodeSynthesisContext::SynthesisKind CSC =
           CodeSynthesisContext::ExplicitTemplateArgumentSubstitution);
 
@@ -14435,8 +14434,7 @@ public:
   // for figuring out the relative 'depth' of the constraint. The depth of the
   // 'primary template' and the 'instantiated from' templates aren't necessarily
   // the same, such as a case when one is a 'friend' defined in a class.
-  bool AreConstraintExpressionsEqual(NamedDecl *Old,
-                                     const Expr *OldConstr,
+  bool AreConstraintExpressionsEqual(NamedDecl *Old, const Expr *OldConstr,
                                      const TemplateCompareNewDeclInfo &New,
                                      const Expr *NewConstr);
 
@@ -14480,8 +14478,9 @@ public:
   DiagnoseUnsatisfiedConstraint(const ASTConstraintSatisfaction &Satisfaction,
                                 bool First = true);
 
-  const NormalizedConstraint *getNormalizedAssociatedConstraints(
-      NamedDecl *ConstrainedDecl, ArrayRef<Expr *> AssociatedConstraints);
+  const NormalizedConstraint *
+  getNormalizedAssociatedConstraints(NamedDecl *ConstrainedDecl,
+                                     ArrayRef<Expr *> AssociatedConstraints);
 
   /// \brief Check whether the given declaration's associated constraints are
   /// at least as constrained than another declaration's according to the
@@ -14499,9 +14498,10 @@ public:
   /// of atomic constraints involved had been declared in a concept and not
   /// repeated in two separate places in code.
   /// \returns true if such a diagnostic was emitted, false otherwise.
-  bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(
-      NamedDecl *D1, ArrayRef<Expr *> AC1, NamedDecl *D2,
-      ArrayRef<Expr *> AC2);
+  bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(NamedDecl *D1,
+                                                     ArrayRef<Expr *> AC1,
+                                                     NamedDecl *D2,
+                                                     ArrayRef<Expr *> AC2);
 
 private:
   /// Caches pairs of template-like decls whose associated constraints were
@@ -14530,18 +14530,19 @@ private:
   /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to recursively(in
   /// the case of lambdas) set up the LocalInstantiationScope of the current
   /// function.
-  bool
-  SetupConstraintScope(FunctionDecl *FD,
-                       std::optional<MutableArrayRef<TemplateArgument>> TemplateArgs,
-                       const MultiLevelTemplateArgumentList &MLTAL,
-                       LocalInstantiationScope &Scope);
+  bool SetupConstraintScope(
+      FunctionDecl *FD,
+      std::optional<MutableArrayRef<TemplateArgument>> TemplateArgs,
+      const MultiLevelTemplateArgumentList &MLTAL,
+      LocalInstantiationScope &Scope);
 
   /// Used during constraint checking, sets up the constraint template argument
   /// lists, and calls SetupConstraintScope to set up the
   /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
   std::optional<MultiLevelTemplateArgumentList>
   SetupConstraintCheckingTemplateArgumentsAndScope(
-      FunctionDecl *FD, std::optional<MutableArrayRef<TemplateArgument>> TemplateArgs,
+      FunctionDecl *FD,
+      std::optional<MutableArrayRef<TemplateArgument>> TemplateArgs,
       LocalInstantiationScope &Scope);
 
   ///@}
diff --git a/clang/include/clang/Sema/SemaConcept.h b/clang/include/clang/Sema/SemaConcept.h
index 1079be3236..00b58b914c 100644
--- a/clang/include/clang/Sema/SemaConcept.h
+++ b/clang/include/clang/Sema/SemaConcept.h
@@ -189,9 +189,9 @@ struct alignas(ConstraintAlignment) FoldExpandedConstraint {
                                           const FoldExpandedConstraint &B);
 };
 
-const NormalizedConstraint *getNormalizedAssociatedConstraints(
-    Sema &S, NamedDecl *ConstrainedDecl,
-    ArrayRef<Expr *> AssociatedConstraints);
+const NormalizedConstraint *
+getNormalizedAssociatedConstraints(Sema &S, NamedDecl *ConstrainedDecl,
+                                   ArrayRef<Expr *> AssociatedConstraints);
 
 template <typename AtomicSubsumptionEvaluator>
 bool subsumes(const NormalForm &PDNF, const NormalForm &QCNF,
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 8c688218ce..747f35737a 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -4165,8 +4165,7 @@ FunctionDecl::getTemplateSpecializationArgs() const {
   return const_cast<FunctionDecl *>(this)->getTemplateSpecializationArgs();
 }
 
-TemplateArgumentList *
-FunctionDecl::getTemplateSpecializationArgs() {
+TemplateArgumentList *FunctionDecl::getTemplateSpecializationArgs() {
   if (FunctionTemplateSpecializationInfo *Info
         = TemplateOrSpecialization
             .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 67afe600d1..2e707acdb5 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -224,8 +224,8 @@ static bool AdoptTemplateParameterList(TemplateParameterList *Params,
   return Invalid;
 }
 
-void TemplateParameterList::
-getAssociatedConstraints(llvm::SmallVectorImpl<Expr *> &AC) {
+void TemplateParameterList::getAssociatedConstraints(
+    llvm::SmallVectorImpl<Expr *> &AC) {
   if (HasConstrainedParameters)
     for (const NamedDecl *Param : *this) {
       if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
@@ -276,8 +276,7 @@ TemplateDecl::TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
 
 void TemplateDecl::anchor() {}
 
-void TemplateDecl::
-getAssociatedConstraints(llvm::SmallVectorImpl<Expr *> &AC) {
+void TemplateDecl::getAssociatedConstraints(llvm::SmallVectorImpl<Expr *> &AC) {
   TemplateParams->getAssociatedConstraints(AC);
   if (auto *FD = dyn_cast_or_null<FunctionDecl>(getTemplatedDecl()))
     if (Expr *TRC = FD->getTrailingRequiresClause())
@@ -396,7 +395,8 @@ void RedeclarableTemplateDecl::addSpecializationImpl(
                                       SETraits::getDecl(Entry));
 }
 
-MutableArrayRef<TemplateArgument> RedeclarableTemplateDecl::getInjectedTemplateArgs() {
+MutableArrayRef<TemplateArgument>
+RedeclarableTemplateDecl::getInjectedTemplateArgs() {
   TemplateParameterList *Params = getTemplateParameters();
   auto *CommonPtr = getCommonPtr();
   if (!CommonPtr->InjectedArgs) {
@@ -412,8 +412,10 @@ MutableArrayRef<TemplateArgument> RedeclarableTemplateDecl::getInjectedTemplateA
   return llvm::MutableArrayRef(CommonPtr->InjectedArgs, Params->size());
 }
 
-ArrayRef<TemplateArgument> RedeclarableTemplateDecl::getInjectedTemplateArgs() const {
-  return const_cast<RedeclarableTemplateDecl *>(this)->getInjectedTemplateArgs();
+ArrayRef<TemplateArgument>
+RedeclarableTemplateDecl::getInjectedTemplateArgs() const {
+  return const_cast<RedeclarableTemplateDecl *>(this)
+      ->getInjectedTemplateArgs();
 }
 
 //===----------------------------------------------------------------------===//
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 6d0a283b05..5dff35500f 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -588,7 +588,8 @@ template <> const TemplateSpecializationType *Type::getAs() const {
 }
 
 template <> TemplateSpecializationType *Type::getAs() {
-  return const_cast<TemplateSpecializationType *>(getAsSugar<TemplateSpecializationType>(this));
+  return const_cast<TemplateSpecializationType *>(
+      getAsSugar<TemplateSpecializationType>(this));
 }
 
 template <> const AttributedType *Type::getAs() const {
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 1947931194..036616299f 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -300,7 +300,8 @@ static bool BuiltinFunctionStart(Sema &S, CallExpr *TheCall) {
     return true;
   }
 
-  return !S.checkAddressOfFunctionIsAvailable(const_cast<FunctionDecl *>(FD), /*Complain=*/true,
+  return !S.checkAddressOfFunctionIsAvailable(const_cast<FunctionDecl *>(FD),
+                                              /*Complain=*/true,
                                               TheCall->getBeginLoc());
 }
 
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index c6c4aaec4f..d960de18e8 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -5569,8 +5569,7 @@ private:
 
   // Gets all the type constraint expressions that might apply to the type
   // variables associated with DC (as returned by getTemplatedEntity()).
-  static SmallVector<Expr *, 1>
-  constraintsForTemplatedEntity(DeclContext *DC) {
+  static SmallVector<Expr *, 1> constraintsForTemplatedEntity(DeclContext *DC) {
     SmallVector<Expr *, 1> Result;
     if (DC == nullptr)
       return Result;
@@ -5578,8 +5577,7 @@ private:
     if (auto *TD = cast<Decl>(DC)->getDescribedTemplate())
       TD->getAssociatedConstraints(Result);
     // Partial specializations may have constraints.
-    if (auto *CTPSD =
-            dyn_cast<ClassTemplatePartialSpecializationDecl>(DC))
+    if (auto *CTPSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(DC))
       CTPSD->getAssociatedConstraints(Result);
     if (auto *VTPSD = dyn_cast<VarTemplatePartialSpecializationDecl>(DC))
       VTPSD->getAssociatedConstraints(Result);
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 19d934b9dd..124ec603bb 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -192,9 +192,8 @@ calculateConstraintSatisfaction(Sema &S, Expr *ConstraintExpr,
 
 template <typename ConstraintEvaluator>
 static ExprResult
-calculateConstraintSatisfaction(Sema &S, Expr *LHS,
-                                OverloadedOperatorKind Op, Expr *RHS,
-                                ConstraintSatisfaction &Satisfaction,
+calculateConstraintSatisfaction(Sema &S, Expr *LHS, OverloadedOperatorKind Op,
+                                Expr *RHS, ConstraintSatisfaction &Satisfaction,
                                 const ConstraintEvaluator &Evaluator) {
   size_t EffectiveDetailEndIndex = Satisfaction.Details.size();
 
@@ -592,7 +591,7 @@ static bool CheckConstraintSatisfaction(
   MutableArrayRef<TemplateArgument> TemplateArgs =
       TemplateArgsLists.getNumSubstitutedLevels() > 0
           ? TemplateArgsLists.getOutermost()
-          : MutableArrayRef<TemplateArgument> {};
+          : MutableArrayRef<TemplateArgument>{};
   Sema::InstantiatingTemplate Inst(S, TemplateIDRange.getBegin(),
       Sema::InstantiatingTemplate::ConstraintsCheck{},
       const_cast<NamedDecl *>(Template), TemplateArgs, TemplateIDRange);
@@ -756,7 +755,8 @@ bool Sema::addInstantiatedCapturesToScope(
 }
 
 bool Sema::SetupConstraintScope(
-    FunctionDecl *FD, std::optional<MutableArrayRef<TemplateArgument>> TemplateArgs,
+    FunctionDecl *FD,
+    std::optional<MutableArrayRef<TemplateArgument>> TemplateArgs,
     const MultiLevelTemplateArgumentList &MLTAL,
     LocalInstantiationScope &Scope) {
   if (FD->isTemplateInstantiation() && FD->getPrimaryTemplate()) {
@@ -775,7 +775,8 @@ bool Sema::SetupConstraintScope(
     // the list of current template arguments to the list so that they also can
     // be picked out of the map.
     if (auto *SpecArgs = FD->getTemplateSpecializationArgs()) {
-      MultiLevelTemplateArgumentList JustTemplArgs(FD, SpecArgs->asMutableArray(),
+      MultiLevelTemplateArgumentList JustTemplArgs(FD,
+                                                   SpecArgs->asMutableArray(),
                                                    /*Final=*/false);
       if (addInstantiatedParametersToScope(
               FD, PrimaryTemplate->getTemplatedDecl(), Scope, JustTemplArgs))
@@ -828,7 +829,8 @@ bool Sema::SetupConstraintScope(
 // constraint-instantiation and checking.
 std::optional<MultiLevelTemplateArgumentList>
 Sema::SetupConstraintCheckingTemplateArgumentsAndScope(
-    FunctionDecl *FD, std::optional<MutableArrayRef<TemplateArgument>> TemplateArgs,
+    FunctionDecl *FD,
+    std::optional<MutableArrayRef<TemplateArgument>> TemplateArgs,
     LocalInstantiationScope &Scope) {
   MultiLevelTemplateArgumentList MLTAL;
 
@@ -911,7 +913,6 @@ bool Sema::CheckFunctionConstraints(FunctionDecl *FD,
       Satisfaction);
 }
 
-
 // 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.
@@ -1008,8 +1009,7 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
   return SubstConstr.get();
 }
 
-bool Sema::AreConstraintExpressionsEqual(NamedDecl *Old,
-                                         const Expr *OldConstr,
+bool Sema::AreConstraintExpressionsEqual(NamedDecl *Old, const Expr *OldConstr,
                                          const TemplateCompareNewDeclInfo &New,
                                          const Expr *NewConstr) {
   if (OldConstr == NewConstr)
@@ -1384,8 +1384,7 @@ void Sema::DiagnoseUnsatisfiedConstraint(
   }
 }
 
-const NormalizedConstraint *
-Sema::getNormalizedAssociatedConstraints(
+const NormalizedConstraint *Sema::getNormalizedAssociatedConstraints(
     NamedDecl *ConstrainedDecl, ArrayRef<Expr *> AssociatedConstraints) {
   // In case the ConstrainedDecl comes from modules, it is necessary to use
   // the canonical decl to avoid different atomic constraints with the 'same'
@@ -1740,10 +1739,8 @@ NormalForm clang::makeDNF(const NormalizedConstraint &Normalized) {
   return Res;
 }
 
-bool Sema::IsAtLeastAsConstrained(NamedDecl *D1,
-                                  MutableArrayRef<Expr *> AC1,
-                                  NamedDecl *D2,
-                                  MutableArrayRef<Expr *> AC2,
+bool Sema::IsAtLeastAsConstrained(NamedDecl *D1, MutableArrayRef<Expr *> AC1,
+                                  NamedDecl *D2, MutableArrayRef<Expr *> AC2,
                                   bool &Result) {
   if (const auto *FD1 = dyn_cast<FunctionDecl>(D1)) {
     auto IsExpectedEntity = [](const FunctionDecl *FD) {
@@ -1803,7 +1800,9 @@ bool Sema::IsAtLeastAsConstrained(NamedDecl *D1,
 }
 
 bool Sema::MaybeEmitAmbiguousAtomicConstraintsDiagnostic(NamedDecl *D1,
-    ArrayRef<Expr *> AC1, NamedDecl *D2, ArrayRef<Expr *> AC2) {
+                                                         ArrayRef<Expr *> AC1,
+                                                         NamedDecl *D2,
+                                                         ArrayRef<Expr *> AC2) {
   if (isSFINAEContext())
     // No need to work here because our notes would be discarded.
     return false;
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index e9f7383439..e50ac197c6 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -11011,8 +11011,7 @@ static bool checkAddressOfFunctionIsAvailable(Sema &S, FunctionDecl *FD,
   return false;
 }
 
-static bool checkAddressOfCandidateIsAvailable(Sema &S,
-                                               FunctionDecl *FD) {
+static bool checkAddressOfCandidateIsAvailable(Sema &S, FunctionDecl *FD) {
   return checkAddressOfFunctionIsAvailable(S, FD, /*Complain=*/true,
                                            /*InOverloadResolution=*/true,
                                            /*Loc=*/SourceLocation());
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 7ac62d3e67..19b3ec3120 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3067,11 +3067,11 @@ bool DeducedArgsNeedReplacement<ClassTemplatePartialSpecializationDecl>(
 }
 
 template <typename TemplateDeclT>
-static TemplateDeductionResult
-CheckDeducedArgumentConstraints(Sema &S, TemplateDeclT *Template,
-                                ArrayRef<TemplateArgument> SugaredDeducedArgs,
-                                MutableArrayRef<TemplateArgument> CanonicalDeducedArgs,
-                                TemplateDeductionInfo &Info) {
+static TemplateDeductionResult CheckDeducedArgumentConstraints(
+    Sema &S, TemplateDeclT *Template,
+    ArrayRef<TemplateArgument> SugaredDeducedArgs,
+    MutableArrayRef<TemplateArgument> CanonicalDeducedArgs,
+    TemplateDeductionInfo &Info) {
   llvm::SmallVector<Expr *, 3> AssociatedConstraints;
   Template->getAssociatedConstraints(AssociatedConstraints);
 
@@ -3523,9 +3523,9 @@ TemplateDeductionResult Sema::SubstituteExplicitTemplateArguments(
 
   ExtParameterInfoBuilder ExtParamInfos;
 
-  MultiLevelTemplateArgumentList MLTAL(FunctionTemplate,
-                                       SugaredExplicitArgumentList->asMutableArray(),
-                                       /*Final=*/true);
+  MultiLevelTemplateArgumentList MLTAL(
+      FunctionTemplate, SugaredExplicitArgumentList->asMutableArray(),
+      /*Final=*/true);
 
   // Instantiate the types of each of the function parameters given the
   // explicitly-specified template arguments. If the function has a trailing
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 15f5cac5dd..a0bc3fb589 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -158,10 +158,9 @@ bool isLambdaEnclosedByTypeAliasDecl(
 }
 
 // Add template arguments from a variable template instantiation.
-Response
-HandleVarTemplateSpec(VarTemplateSpecializationDecl *VarTemplSpec,
-                      MultiLevelTemplateArgumentList &Result,
-                      bool SkipForSpecialization) {
+Response HandleVarTemplateSpec(VarTemplateSpecializationDecl *VarTemplSpec,
+                               MultiLevelTemplateArgumentList &Result,
+                               bool SkipForSpecialization) {
   // For a class-scope explicit specialization, there are no template arguments
   // at this level, but there may be enclosing template arguments.
   if (VarTemplSpec->isClassScopeExplicitSpecialization())
@@ -181,7 +180,8 @@ HandleVarTemplateSpec(VarTemplateSpecializationDecl *VarTemplSpec,
           Specialized.dyn_cast<VarTemplatePartialSpecializationDecl *>()) {
     if (!SkipForSpecialization)
       Result.addOuterTemplateArguments(
-          Partial, VarTemplSpec->getTemplateInstantiationArgs().asMutableArray(),
+          Partial,
+          VarTemplSpec->getTemplateInstantiationArgs().asMutableArray(),
           /*Final=*/false);
     if (Partial->isMemberSpecialization())
       return Response::Done();
@@ -272,8 +272,7 @@ Response HandleFunction(Sema &SemaRef, FunctionDecl *Function,
   } else if (TemplateArgumentList *TemplateArgs =
                  Function->getTemplateSpecializationArgs()) {
     // Add the template arguments for this specialization.
-    Result.addOuterTemplateArguments(Function,
-                                     TemplateArgs->asMutableArray(),
+    Result.addOuterTemplateArguments(Function, TemplateArgs->asMutableArray(),
                                      /*Final=*/false);
 
     if (RelativeToPrimary &&
@@ -332,17 +331,16 @@ Response HandleFunction(Sema &SemaRef, FunctionDecl *Function,
 Response HandleFunctionTemplateDecl(FunctionTemplateDecl *FTD,
                                     MultiLevelTemplateArgumentList &Result) {
   if (!isa<ClassTemplateSpecializationDecl>(FTD->getDeclContext())) {
-    Result.addOuterTemplateArguments(
-        FTD,
-        FTD->getInjectedTemplateArgs(),
-        /*Final=*/false);
+    Result.addOuterTemplateArguments(FTD, FTD->getInjectedTemplateArgs(),
+                                     /*Final=*/false);
 
     NestedNameSpecifier *NNS = FTD->getTemplatedDecl()->getQualifier();
 
     while (Type *Ty = NNS ? NNS->getAsType() : nullptr) {
       if (NNS->isInstantiationDependent()) {
         if (auto *TSTy = Ty->getAs<TemplateSpecializationType>()) {
-          MutableArrayRef<TemplateArgument> Arguments = TSTy->template_arguments();
+          MutableArrayRef<TemplateArgument> Arguments =
+              TSTy->template_arguments();
           // Prefer template arguments from the injected-class-type if possible.
           // For example,
           // ```cpp
@@ -366,8 +364,8 @@ Response HandleFunctionTemplateDecl(FunctionTemplateDecl *FTD,
               Arguments = CTD->getInjectedTemplateArgs();
             else if (auto *Specialization =
                          dyn_cast<ClassTemplateSpecializationDecl>(RD))
-              Arguments =
-                  Specialization->getTemplateInstantiationArgs().asMutableArray();
+              Arguments = Specialization->getTemplateInstantiationArgs()
+                              .asMutableArray();
           }
           Result.addOuterTemplateArguments(FTD, Arguments, /*Final=*/false);
         }
@@ -449,10 +447,8 @@ Response HandleRecordDecl(Sema &SemaRef, const CXXRecordDecl *Rec,
 Response HandleImplicitConceptSpecializationDecl(
     ImplicitConceptSpecializationDecl *CSD,
     MultiLevelTemplateArgumentList &Result) {
-  Result.addOuterTemplateArguments(
-      CSD,
-      CSD->getTemplateArguments(),
-      /*Final=*/false);
+  Result.addOuterTemplateArguments(CSD, CSD->getTemplateArguments(),
+                                   /*Final=*/false);
   return Response::UseNextDecl(CSD);
 }
 
@@ -464,9 +460,9 @@ Response HandleGenericDeclContext(const Decl *CurDecl) {
 
 MultiLevelTemplateArgumentList Sema::getTemplateInstantiationArgs(
     NamedDecl *ND, const DeclContext *DC, bool Final,
-    std::optional<MutableArrayRef<TemplateArgument>> Innermost, bool RelativeToPrimary,
-    const FunctionDecl *Pattern, bool ForConstraintInstantiation,
-    bool SkipForSpecialization) {
+    std::optional<MutableArrayRef<TemplateArgument>> Innermost,
+    bool RelativeToPrimary, const FunctionDecl *Pattern,
+    bool ForConstraintInstantiation, bool SkipForSpecialization) {
   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;
@@ -494,8 +490,7 @@ MultiLevelTemplateArgumentList Sema::getTemplateInstantiationArgs(
 
   while (!CurDecl->isFileContextDecl()) {
     Response R;
-    if (auto *VarTemplSpec =
-            dyn_cast<VarTemplateSpecializationDecl>(CurDecl)) {
+    if (auto *VarTemplSpec = dyn_cast<VarTemplateSpecializationDecl>(CurDecl)) {
       R = HandleVarTemplateSpec(VarTemplSpec, Result, SkipForSpecialization);
     } else if (const auto *PartialClassTemplSpec =
                    dyn_cast<ClassTemplatePartialSpecializationDecl>(CurDecl)) {
@@ -581,7 +576,8 @@ bool Sema::CodeSynthesisContext::isInstantiationRecord() const {
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, CodeSynthesisContext::SynthesisKind Kind,
     SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
-    Decl *Entity, NamedDecl *Template, MutableArrayRef<TemplateArgument> TemplateArgs,
+    Decl *Entity, NamedDecl *Template,
+    MutableArrayRef<TemplateArgument> TemplateArgs,
     sema::TemplateDeductionInfo *DeductionInfo)
     : SemaRef(SemaRef) {
   // Don't allow further instantiation if a fatal error and an uncompilable
@@ -632,8 +628,7 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
     TemplateDecl *Template, MutableArrayRef<TemplateArgument> TemplateArgs,
     SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef,
-          CodeSynthesisContext::DefaultTemplateArgumentInstantiation,
+          SemaRef, CodeSynthesisContext::DefaultTemplateArgumentInstantiation,
           PointOfInstantiation, InstantiationRange, getAsNamedDecl(Param),
           Template, TemplateArgs) {}
 
@@ -652,13 +647,11 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
 }
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
-    Sema &SemaRef, SourceLocation PointOfInstantiation,
-    TemplateDecl *Template,
+    Sema &SemaRef, SourceLocation PointOfInstantiation, TemplateDecl *Template,
     MutableArrayRef<TemplateArgument> TemplateArgs,
     sema::TemplateDeductionInfo &DeductionInfo, SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef,
-          CodeSynthesisContext::DeducedTemplateArgumentSubstitution,
+          SemaRef, CodeSynthesisContext::DeducedTemplateArgumentSubstitution,
           PointOfInstantiation, InstantiationRange, Template, nullptr,
           TemplateArgs, &DeductionInfo) {}
 
@@ -668,8 +661,7 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
     MutableArrayRef<TemplateArgument> TemplateArgs,
     sema::TemplateDeductionInfo &DeductionInfo, SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef,
-          CodeSynthesisContext::DeducedTemplateArgumentSubstitution,
+          SemaRef, CodeSynthesisContext::DeducedTemplateArgumentSubstitution,
           PointOfInstantiation, InstantiationRange, PartialSpec, nullptr,
           TemplateArgs, &DeductionInfo) {}
 
@@ -679,43 +671,43 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
     MutableArrayRef<TemplateArgument> TemplateArgs,
     sema::TemplateDeductionInfo &DeductionInfo, SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef,
-          CodeSynthesisContext::DeducedTemplateArgumentSubstitution,
+          SemaRef, CodeSynthesisContext::DeducedTemplateArgumentSubstitution,
           PointOfInstantiation, InstantiationRange, PartialSpec, nullptr,
           TemplateArgs, &DeductionInfo) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, ParmVarDecl *Param,
-    MutableArrayRef<TemplateArgument> TemplateArgs, SourceRange InstantiationRange)
+    MutableArrayRef<TemplateArgument> TemplateArgs,
+    SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef,
-          CodeSynthesisContext::DefaultFunctionArgumentInstantiation,
+          SemaRef, CodeSynthesisContext::DefaultFunctionArgumentInstantiation,
           PointOfInstantiation, InstantiationRange, Param, nullptr,
           TemplateArgs) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, NamedDecl *Template,
-    NonTypeTemplateParmDecl *Param, MutableArrayRef<TemplateArgument> TemplateArgs,
+    NonTypeTemplateParmDecl *Param,
+    MutableArrayRef<TemplateArgument> TemplateArgs,
     SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef,
-          CodeSynthesisContext::PriorTemplateArgumentSubstitution,
+          SemaRef, CodeSynthesisContext::PriorTemplateArgumentSubstitution,
           PointOfInstantiation, InstantiationRange, Param, Template,
           TemplateArgs) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, NamedDecl *Template,
-    TemplateTemplateParmDecl *Param, MutableArrayRef<TemplateArgument> TemplateArgs,
+    TemplateTemplateParmDecl *Param,
+    MutableArrayRef<TemplateArgument> TemplateArgs,
     SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef,
-          CodeSynthesisContext::PriorTemplateArgumentSubstitution,
+          SemaRef, CodeSynthesisContext::PriorTemplateArgumentSubstitution,
           PointOfInstantiation, InstantiationRange, Param, Template,
           TemplateArgs) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation,
-    TypeAliasTemplateDecl *Entity, MutableArrayRef<TemplateArgument> TemplateArgs,
+    TypeAliasTemplateDecl *Entity,
+    MutableArrayRef<TemplateArgument> TemplateArgs,
     SourceRange InstantiationRange)
     : InstantiatingTemplate(
           SemaRef, CodeSynthesisContext::TypeAliasTemplateInstantiation,
@@ -760,13 +752,12 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
 }
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
-    Sema &SemaRef, SourceLocation PointOfInstantiation,
-    ConstraintsCheck, NamedDecl *Template,
-    MutableArrayRef<TemplateArgument> TemplateArgs, SourceRange InstantiationRange)
-    : InstantiatingTemplate(
-          SemaRef, CodeSynthesisContext::ConstraintsCheck,
-          PointOfInstantiation, InstantiationRange, Template, nullptr,
-          TemplateArgs) {}
+    Sema &SemaRef, SourceLocation PointOfInstantiation, ConstraintsCheck,
+    NamedDecl *Template, MutableArrayRef<TemplateArgument> TemplateArgs,
+    SourceRange InstantiationRange)
+    : InstantiatingTemplate(SemaRef, CodeSynthesisContext::ConstraintsCheck,
+                            PointOfInstantiation, InstantiationRange, Template,
+                            nullptr, TemplateArgs) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation,
@@ -3244,7 +3235,8 @@ bool Sema::SubstDefaultArgument(
                                              TemplateArgs.getInnermost());
         NewTemplateArgs = getTemplateInstantiationArgs(
             FD, FD->getDeclContext(), /*Final=*/false,
-            CurrentTemplateArgumentList->asMutableArray(), /*RelativeToPrimary=*/true);
+            CurrentTemplateArgumentList->asMutableArray(),
+            /*RelativeToPrimary=*/true);
       }
     }
 
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 7234b50187..e60ec5ad02 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4901,12 +4901,13 @@ bool TemplateDeclInstantiator::SubstDefaultedFunction(FunctionDecl *New,
 }
 
 FunctionDecl *Sema::InstantiateFunctionDeclaration(
-    FunctionTemplateDecl *FTD, TemplateArgumentList *Args,
-    SourceLocation Loc, CodeSynthesisContext::SynthesisKind CSC) {
+    FunctionTemplateDecl *FTD, TemplateArgumentList *Args, SourceLocation Loc,
+    CodeSynthesisContext::SynthesisKind CSC) {
   FunctionDecl *FD = FTD->getTemplatedDecl();
 
   sema::TemplateDeductionInfo Info(Loc);
-  InstantiatingTemplate Inst(*this, Loc, FTD, Args->asMutableArray(), CSC, Info);
+  InstantiatingTemplate Inst(*this, Loc, FTD, Args->asMutableArray(), CSC,
+                             Info);
   if (Inst.isInvalid())
     return nullptr;
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/104687


More information about the cfe-commits mailing list