[clang] [Clang][AST] Store injected template arguments in TemplateParameterList (PR #113579)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 25 09:36:58 PDT 2024


================
@@ -51,14 +51,15 @@ DefaultTemplateArgumentContainsUnexpandedPack(const TemplateParam &P) {
          P.getDefaultArgument().getArgument().containsUnexpandedParameterPack();
 }
 
-TemplateParameterList::TemplateParameterList(const ASTContext& C,
+TemplateParameterList::TemplateParameterList(const ASTContext &C,
                                              SourceLocation TemplateLoc,
                                              SourceLocation LAngleLoc,
                                              ArrayRef<NamedDecl *> Params,
                                              SourceLocation RAngleLoc,
                                              Expr *RequiresClause)
-    : TemplateLoc(TemplateLoc), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc),
-      NumParams(Params.size()), ContainsUnexpandedParameterPack(false),
+    : InjectedArgs(&C), TemplateLoc(TemplateLoc), LAngleLoc(LAngleLoc),
----------------
erichkeane wrote:

This trickery with storing the ASTContext seems a little silly. I would vastly prefer one of the following:

1- We just store the AST Context reference in this type.
2- We make `getInjectedTemplateArgs` take an `ASTContext` reference.
3- We take a collection in `getInjectedTemplateArgs` and just fill it.
4- We DON'T have this function (or do #2), and keep the `ASTContext` version of this function to do the work.

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


More information about the cfe-commits mailing list