26#include "llvm/Support/TrailingObjects.h"
33ConceptSpecializationExpr::ConceptSpecializationExpr(
38 ConceptRef(
Loc), SpecDecl(SpecDecl),
39 Satisfaction(Satisfaction
45 assert(!
Loc->getNestedNameSpecifierLoc() ||
46 (!
Loc->getNestedNameSpecifierLoc()
47 .getNestedNameSpecifier()
48 ->isInstantiationDependent() &&
49 !
Loc->getNestedNameSpecifierLoc()
50 .getNestedNameSpecifier()
51 ->containsUnexpandedParameterPack()));
52 assert((!isValueDependent() || isInstantiationDependent()) &&
53 "should not be value-dependent");
56ConceptSpecializationExpr::ConceptSpecializationExpr(EmptyShell
Empty)
57 :
Expr(ConceptSpecializationExprClass,
Empty) {}
66ConceptSpecializationExpr::ConceptSpecializationExpr(
70 bool ContainsUnexpandedParameterPack)
72 ConceptRef(
Loc), SpecDecl(SpecDecl),
73 Satisfaction(Satisfaction
78 D |= ExprDependence::Value;
80 D |= ExprDependence::Instantiation;
81 if (ContainsUnexpandedParameterPack)
82 D |= ExprDependence::UnexpandedPack;
91 bool ContainsUnexpandedParameterPack) {
94 ContainsUnexpandedParameterPack);
102 return cast<TemplateTypeParmDecl>(TPL->getParam(0))
103 ->getTypeConstraint();
109 if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(R))
110 return ExprReq->getExpr() && ExprReq->getExpr()->containsErrors();
112 if (
auto *NestedReq = dyn_cast<concepts::NestedRequirement>(R))
113 return !NestedReq->hasInvalidConstraint() &&
114 NestedReq->getConstraintExpr() &&
115 NestedReq->getConstraintExpr()->containsErrors();
126 NumLocalParameters(LocalParameters.size()),
127 NumRequirements(Requirements.size()), Body(Body), LParenLoc(LParenLoc),
128 RParenLoc(RParenLoc), RBraceLoc(RBraceLoc) {
129 RequiresExprBits.IsSatisfied =
false;
130 RequiresExprBits.RequiresKWLoc = RequiresKWLoc;
132 bool ContainsUnexpandedParameterPack =
false;
134 Dependent |=
P->getType()->isInstantiationDependentType();
135 ContainsUnexpandedParameterPack |=
136 P->getType()->containsUnexpandedParameterPack();
138 RequiresExprBits.IsSatisfied =
true;
141 ContainsUnexpandedParameterPack |= R->containsUnexpandedParameterPack();
143 RequiresExprBits.IsSatisfied = R->isSatisfied();
144 if (!RequiresExprBits.IsSatisfied)
149 setDependence(getDependence() | ExprDependence::Error);
151 std::copy(LocalParameters.begin(), LocalParameters.end(),
152 getTrailingObjects<ParmVarDecl *>());
153 std::copy(Requirements.begin(), Requirements.end(),
154 getTrailingObjects<concepts::Requirement *>());
155 RequiresExprBits.IsSatisfied |=
Dependent;
157 if (ContainsUnexpandedParameterPack)
158 setDependence(getDependence() | ExprDependence::UnexpandedPack);
164 setDependence(getDependence() | ExprDependence::ValueInstantiation);
168 unsigned NumLocalParameters,
169 unsigned NumRequirements)
170 :
Expr(RequiresExprClass,
Empty), NumLocalParameters(NumLocalParameters),
171 NumRequirements(NumRequirements) { }
179 C.Allocate(totalSizeToAlloc<ParmVarDecl *, concepts::Requirement *>(
180 LocalParameters.size(), Requirements.size()),
183 RequiresExpr(
C, RequiresKWLoc, Body, LParenLoc, LocalParameters,
184 RParenLoc, Requirements, RBraceLoc);
189 unsigned NumLocalParameters,
unsigned NumRequirements) {
191 C.Allocate(totalSizeToAlloc<ParmVarDecl *, concepts::Requirement *>(
192 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.
Stores a list of template parameters for a TemplateDecl and its derived classes.
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.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ OK_Ordinary
An ordinary object is located at an address in memory.
ExprDependence computeDependence(FullExpr *E)
@ 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....