[PATCH] D60939: [Concepts] Delayed Constraint Substitution
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 1 14:48:36 PDT 2020
rsmith added a comment.
I wonder if there's a cleaner way to model this:
Suppose we add a new `Expr` subclass for an expression with delayed template argument substitution, which would capture a list of `TemplateArgument`s and an inner `Expr*` into which those template arguments have not yet been substituted. Then when we transform a trailing requires-clause, we can wrap it suitably with that expression node, and similarly when we transform a `TypeConstraint` we can wrap the immediately-declared constraint in the partial substitution wrapper.
We'd need to teach normalization to pick up the wrapper and turn it into a parameter mapping, and we'd need to teach satisfaction checking to actually substitute that partially-substituted wrapper, but I think the result would be a bit simpler and wouldn't need us to carefully keep track of whether each individual constraint is substituted or not. What do you think?
================
Comment at: include/clang/AST/DeclTemplate.h:70-71
: private llvm::TrailingObjects<TemplateParameterList, NamedDecl *,
- Expr *> {
+ llvm::PointerUnion<Expr *,
+ TemplateParameterList *>> {
/// The location of the 'template' keyword.
----------------
Please can you introduce a typedef or wrapper type for this? Maybe a `struct TemplateHeadConstraints` or similar?
================
Comment at: include/clang/AST/DeclTemplate.h:96-97
SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
- SourceLocation RAngleLoc, Expr *RequiresClause);
+ SourceLocation RAngleLoc, Expr *RequiresClause,
+ TemplateParameterList *InheritedConstraints);
----------------
Consider passing the union type (whatever it's called) here instead of having an `Expr*` argument and a `TemplateParameterList*` argument, at least one of which must be null.
================
Comment at: include/clang/AST/DeclTemplate.h:1276
+ };
+ llvm::PointerIntPair<TemplateTypeParmDecl *, 2, TypeConstraintStatus>
+ TypeConstraintStatus;
----------------
Is it feasible to tail-allocate the pointer? (At least in the case where there is no type-constraint, it'd be nice to avoid allocating storage for it; allocating it unconditionally along with the `TypeConstraint` seems good enough to me.)
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60939/new/
https://reviews.llvm.org/D60939
More information about the cfe-commits
mailing list