30ConceptSpecializationExpr::ConceptSpecializationExpr(
35 ConceptRef(
Loc), SpecDecl(SpecDecl),
36 Satisfaction(Satisfaction
42 assert(!
Loc->getNestedNameSpecifierLoc() ||
43 (!
Loc->getNestedNameSpecifierLoc()
44 .getNestedNameSpecifier()
45 ->isInstantiationDependent() &&
46 !
Loc->getNestedNameSpecifierLoc()
47 .getNestedNameSpecifier()
48 ->containsUnexpandedParameterPack()));
49 assert((!isValueDependent() || isInstantiationDependent()) &&
50 "should not be value-dependent");
53ConceptSpecializationExpr::ConceptSpecializationExpr(EmptyShell
Empty)
54 :
Expr(ConceptSpecializationExprClass,
Empty) {}
63ConceptSpecializationExpr::ConceptSpecializationExpr(
67 bool ContainsUnexpandedParameterPack)
69 ConceptRef(
Loc), SpecDecl(SpecDecl),
70 Satisfaction(Satisfaction
75 D |= ExprDependence::Value;
77 D |= ExprDependence::Instantiation;
78 if (ContainsUnexpandedParameterPack)
79 D |= ExprDependence::UnexpandedPack;
88 bool ContainsUnexpandedParameterPack) {
91 ContainsUnexpandedParameterPack);
97 auto TPL = cast<TemplateParameterList *>(TypeConstraintInfo.getPointer());
98 return cast<TemplateTypeParmDecl>(TPL->getParam(0))
99 ->getTypeConstraint();
105 if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(R))
106 return ExprReq->getExpr() && ExprReq->getExpr()->containsErrors();
108 if (
auto *NestedReq = dyn_cast<concepts::NestedRequirement>(R))
109 return !NestedReq->hasInvalidConstraint() &&
110 NestedReq->getConstraintExpr() &&
111 NestedReq->getConstraintExpr()->containsErrors();
122 NumLocalParameters(LocalParameters.size()),
123 NumRequirements(Requirements.size()), Body(Body), LParenLoc(LParenLoc),
124 RParenLoc(RParenLoc), RBraceLoc(RBraceLoc) {
125 RequiresExprBits.IsSatisfied =
false;
126 RequiresExprBits.RequiresKWLoc = RequiresKWLoc;
128 bool ContainsUnexpandedParameterPack =
false;
130 Dependent |=
P->getType()->isInstantiationDependentType();
131 ContainsUnexpandedParameterPack |=
132 P->getType()->containsUnexpandedParameterPack();
134 RequiresExprBits.IsSatisfied =
true;
137 ContainsUnexpandedParameterPack |= R->containsUnexpandedParameterPack();
139 RequiresExprBits.IsSatisfied = R->isSatisfied();
140 if (!RequiresExprBits.IsSatisfied)
145 setDependence(getDependence() | ExprDependence::Error);
147 std::copy(LocalParameters.begin(), LocalParameters.end(),
148 getTrailingObjects<ParmVarDecl *>());
149 std::copy(Requirements.begin(), Requirements.end(),
150 getTrailingObjects<concepts::Requirement *>());
151 RequiresExprBits.IsSatisfied |=
Dependent;
153 if (ContainsUnexpandedParameterPack)
154 setDependence(getDependence() | ExprDependence::UnexpandedPack);
160 setDependence(getDependence() | ExprDependence::ValueInstantiation);
164 unsigned NumLocalParameters,
165 unsigned NumRequirements)
166 :
Expr(RequiresExprClass,
Empty), NumLocalParameters(NumLocalParameters),
167 NumRequirements(NumRequirements) { }
175 C.Allocate(totalSizeToAlloc<ParmVarDecl *, concepts::Requirement *>(
176 LocalParameters.size(), Requirements.size()),
179 RequiresExpr(
C, RequiresKWLoc, Body, LParenLoc, LocalParameters,
180 RParenLoc, Requirements, RBraceLoc);
185 unsigned NumLocalParameters,
unsigned NumRequirements) {
187 C.Allocate(totalSizeToAlloc<ParmVarDecl *, concepts::Requirement *>(
188 NumLocalParameters, NumRequirements),
This file provides AST data structures related to concepts.
Defines the clang::ASTContext interface.
Defines the C++ template declaration subclasses.
static bool RequirementContainsError(concepts::Requirement *R)
Defines Expressions and AST nodes for C++2a concepts.
Defines the clang::SourceLocation class and associated facilities.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A reference to a concept and its template args, as it appears in the code.
Represents the specialization of a concept - evaluates to a prvalue of type bool.
static ConceptSpecializationExpr * Create(const ASTContext &C, ConceptReference *ConceptRef, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
This represents one expression.
void setDependence(ExprDependence Deps)
Each concrete expr subclass is expected to compute its dependence and call this in the constructor.
Represents a parameter to a function.
Represents the body of a requires-expression.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
Encodes a location in the source.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
bool isTypeConstraint() const
const TypeConstraint * getTypeConstraint() const
A static requirement that can be used in a requires-expression to check properties of types and expre...
The JSON file list parser is used to communicate input to InstallAPI.
@ OK_Ordinary
An ordinary object is located at an address in memory.
ExprDependence computeDependence(FullExpr *E)
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....