26#include "llvm/Support/TrailingObjects.h"
42 NamedConcept, ArgsAsWritten),
44 Satisfaction(Satisfaction
55 "should not be value-dependent");
59 :
Expr(ConceptSpecializationExprClass, Empty) {}
78 bool ContainsUnexpandedParameterPack)
84 Satisfaction(Satisfaction
89 D |= ExprDependence::Value;
91 D |= ExprDependence::Instantiation;
92 if (ContainsUnexpandedParameterPack)
93 D |= ExprDependence::UnexpandedPack;
102 bool ContainsUnexpandedParameterPack) {
105 ContainsUnexpandedParameterPack);
113 return cast<TemplateTypeParmDecl>(TPL->getParam(0))
114 ->getTypeConstraint();
120 if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(R))
121 return ExprReq->getExpr() && ExprReq->getExpr()->containsErrors();
123 if (
auto *NestedReq = dyn_cast<concepts::NestedRequirement>(R))
124 return !NestedReq->hasInvalidConstraint() &&
125 NestedReq->getConstraintExpr() &&
126 NestedReq->getConstraintExpr()->containsErrors();
136 NumLocalParameters(LocalParameters.size()),
137 NumRequirements(Requirements.size()), Body(Body), RBraceLoc(RBraceLoc) {
138 RequiresExprBits.IsSatisfied =
false;
139 RequiresExprBits.RequiresKWLoc = RequiresKWLoc;
140 bool Dependent =
false;
141 bool ContainsUnexpandedParameterPack =
false;
143 Dependent |=
P->getType()->isInstantiationDependentType();
144 ContainsUnexpandedParameterPack |=
145 P->getType()->containsUnexpandedParameterPack();
147 RequiresExprBits.IsSatisfied =
true;
149 Dependent |= R->isDependent();
150 ContainsUnexpandedParameterPack |= R->containsUnexpandedParameterPack();
152 RequiresExprBits.IsSatisfied = R->isSatisfied();
153 if (!RequiresExprBits.IsSatisfied)
158 setDependence(getDependence() | ExprDependence::Error);
160 std::copy(LocalParameters.begin(), LocalParameters.end(),
161 getTrailingObjects<ParmVarDecl *>());
162 std::copy(Requirements.begin(), Requirements.end(),
163 getTrailingObjects<concepts::Requirement *>());
164 RequiresExprBits.IsSatisfied |= Dependent;
166 if (ContainsUnexpandedParameterPack)
167 setDependence(getDependence() | ExprDependence::UnexpandedPack);
173 setDependence(getDependence() | ExprDependence::ValueInstantiation);
176RequiresExpr::RequiresExpr(
ASTContext &
C, EmptyShell Empty,
177 unsigned NumLocalParameters,
178 unsigned NumRequirements)
179 :
Expr(RequiresExprClass, Empty), NumLocalParameters(NumLocalParameters),
180 NumRequirements(NumRequirements) { }
189 C.Allocate(totalSizeToAlloc<ParmVarDecl *, concepts::Requirement *>(
190 LocalParameters.size(), Requirements.size()),
192 return new (Mem)
RequiresExpr(
C, RequiresKWLoc, Body, LocalParameters,
193 Requirements, RBraceLoc);
198 unsigned NumLocalParameters,
unsigned NumRequirements) {
200 C.Allocate(totalSizeToAlloc<ParmVarDecl *, concepts::Requirement *>(
201 NumLocalParameters, NumRequirements),
203 return new (Mem)
RequiresExpr(
C, Empty, 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 ...
Declaration of a C++20 concept.
Common data class for constructs that reference concepts with template arguments.
NestedNameSpecifierLoc NestedNameSpec
ConceptDecl * NamedConcept
The concept named.
SourceLocation TemplateKWLoc
The location of the template keyword, if specified when naming the concept.
const ASTTemplateArgumentListInfo * ArgsAsWritten
The template argument list source info used to specialize the concept.
NamedDecl * FoundDecl
The declaration found by name lookup when the expression was created.
Represents the specialization of a concept - evaluates to a prvalue of type bool.
ASTConstraintSatisfaction * Satisfaction
Information about the satisfaction of the named concept with the given arguments.
static ConceptSpecializationExpr * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
ImplicitConceptSpecializationDecl * SpecDecl
The Implicit Concept Specialization Decl, which holds the template arguments for this specialization.
ConceptSpecializationExpr(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
void setDependence(ExprDependence Deps)
Each concrete expr subclass is expected to compute its dependence and call this in the constructor.
This represents a decl that may have a name.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isInstantiationDependent() const
Whether this nested name specifier involves a template parameter.
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
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, ArrayRef< ParmVarDecl * > LocalParameters, 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.
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...
@ OK_Ordinary
An ordinary object is located at an address in memory.
ExprDependence computeDependence(FullExpr *E)
@ C
Languages that the frontend can parse and compile.
@ 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...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....