[clang] [Clang][C++26] Implement P3865R1 - CTAD for type template template parameters (PR #191409)

via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 23 03:02:16 PDT 2026


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 origin/main HEAD --extensions h,cpp -- clang/test/SemaCXX/cxx2c-ctad-type-template.cpp clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaInit.cpp clang/lib/Sema/SemaTemplateDeductionGuide.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp clang/test/AST/ast-dump-ctad-alias.cpp clang/test/SemaTemplate/nested-implicit-deduction-guides.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index c3f896aeb..3c202fcda 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -1601,7 +1601,7 @@ TypeAliasTemplateDecl *Sema::BuildAliasForCTADFromTypeTemplateParameter(
   ASTContext &AST = getASTContext();
   DeclContext *Ctx = CurContext;
 
-  while(Ctx->isRequiresExprBody())
+  while (Ctx->isRequiresExprBody())
     Ctx = Ctx->getParent();
 
   Ctx = Ctx->isFileContext() ? Ctx : Ctx->getLexicalParent();
@@ -1614,26 +1614,25 @@ TypeAliasTemplateDecl *Sema::BuildAliasForCTADFromTypeTemplateParameter(
   llvm::SmallVector<TemplateArgument> Args;
   for (NamedDecl *P : D->getTemplateParameters()->asArray()) {
     auto [Depth, Index] = getDepthAndIndex(P);
-    NamedDecl *NewParam =
-        transformTemplateParameter(*this, Ctx, P, MLTAL, Index, Depth? Depth -1 : 0);
+    NamedDecl *NewParam = transformTemplateParameter(
+        *this, Ctx, P, MLTAL, Index, Depth ? Depth - 1 : 0);
     if (!NewParam)
       return nullptr;
     Parameters.push_back(NewParam);
     Args.push_back(SemaRef.Context.getInjectedTemplateArg(NewParam));
   }
 
-  auto *ParamList =
-      TemplateParameterList::Create(AST, SourceLocation(), SourceLocation(),
-                                    Parameters, SourceLocation(),
-                                    /*RequiresClause=*/nullptr);
+  auto *ParamList = TemplateParameterList::Create(
+      AST, SourceLocation(), SourceLocation(), Parameters, SourceLocation(),
+      /*RequiresClause=*/nullptr);
 
   QualType Type = AST.getCanonicalType(AST.getTemplateSpecializationType(
       ElaboratedTypeKeyword::Class, Replacement, Args, {}));
 
   // FIXME: Have a flag to distinguish such special type alias declarations.
-  auto *Alias = TypeAliasDecl::Create(AST, Ctx, Loc, /*IdLoc=*/SourceLocation(),
-                                      /*Id=*/nullptr,
-                                      AST.getTrivialTypeSourceInfo(Type));
+  auto *Alias =
+      TypeAliasDecl::Create(AST, Ctx, Loc, /*IdLoc=*/SourceLocation(),
+                            /*Id=*/nullptr, AST.getTrivialTypeSourceInfo(Type));
   Alias->setImplicit(true);
 
   auto *Template = TypeAliasTemplateDecl::Create(

``````````

</details>


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


More information about the cfe-commits mailing list