14 #ifndef LLVM_CLANG_AST_EXPRCONCEPTS_H 15 #define LLVM_CLANG_AST_EXPRCONCEPTS_H 27 #include "llvm/Support/TrailingObjects.h" 70 bool ContainsUnexpandedParameterPack);
89 bool ContainsUnexpandedParameterPack);
107 &&
"isSatisfied called on a dependent ConceptSpecializationExpr");
116 &&
"getSatisfaction called on dependent ConceptSpecializationExpr");
121 return T->
getStmtClass() == ConceptSpecializationExprClass;
153 bool ContainsUnexpandedParameterPack : 1;
166 bool ContainsUnexpandedParameterPack,
bool IsSatisfied =
true) :
167 Kind(Kind), Dependent(IsDependent),
168 ContainsUnexpandedParameterPack(ContainsUnexpandedParameterPack),
169 Satisfied(IsSatisfied) {}
175 "isSatisfied can only be called on non-dependent requirements.");
181 "setSatisfied can only be called on non-dependent requirements.");
182 Satisfied = IsSatisfied;
189 ContainsUnexpandedParameterPack = Contains;
192 return ContainsUnexpandedParameterPack;
206 llvm::PointerUnion<SubstitutionDiagnostic *, TypeSourceInfo *>
Value;
222 Status(SS_SubstitutionFailure) {}
226 this->Status = Status;
230 return Status == SS_SubstitutionFailure;
234 assert(Status == SS_SubstitutionFailure &&
235 "Attempted to get substitution diagnostic when there has been no " 236 "substitution failure.");
241 assert(!isSubstitutionFailure() &&
242 "Attempted to get type when there has been a substitution failure.");
247 return R->
getKind() == RK_Type;
264 llvm::PointerIntPair<
265 llvm::PointerUnion<TemplateParameterList *, SubstitutionDiagnostic *>,
278 TypeConstraintInfo(SubstDiag, 0) {}
289 return TypeConstraintInfo.getInt();
293 if (!isTypeConstraint())
295 return getTypeConstraintTemplateParameterList()
296 ->containsUnexpandedParameterPack();
300 return TypeConstraintInfo.getPointer().isNull();
314 assert(isSubstitutionFailure());
321 assert(isTypeConstraint());
326 llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>
Value;
368 return Status == SS_ExprSubstitutionFailure;
377 assert(Status >= SS_TypeRequirementSubstitutionFailure);
378 return SubstitutedConstraintExpr;
382 assert(isExprSubstitutionFailure() &&
383 "Attempted to get expression substitution diagnostic when there has " 384 "been no expression substitution failure");
389 assert(!isExprSubstitutionFailure() &&
390 "ExprRequirement has no expression because there has been a " 391 "substitution failure.");
392 return Value.get<
Expr *>();
403 llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>
Value;
413 false), Value(SubstDiag) {}
420 "Nested requirement with non-dependent constraint must be " 421 "constructed with a ConstraintSatisfaction object");
428 Satisfaction.IsSatisfied),
437 assert(isSubstitutionFailure() &&
438 "getSubstitutionDiagnostic() may not be called when there was no " 439 "substitution failure.");
444 assert(!isSubstitutionFailure() &&
"getConstraintExpr() may not be called " 445 "on nested requirements with " 446 "substitution failures.");
447 return Value.get<
Expr *>();
451 assert(!isSubstitutionFailure() &&
"getConstraintSatisfaction() may not be " 452 "called on nested requirements with " 453 "substitution failures.");
458 return R->
getKind() == RK_Nested;
472 concepts::Requirement *> {
476 unsigned NumLocalParameters;
477 unsigned NumRequirements;
481 unsigned numTrailingObjects(OverloadToken<ParmVarDecl *>)
const {
482 return NumLocalParameters;
485 unsigned numTrailingObjects(OverloadToken<concepts::Requirement *>)
const {
486 return NumRequirements;
495 unsigned NumRequirements);
505 unsigned NumRequirements);
508 return {getTrailingObjects<ParmVarDecl *>(), NumLocalParameters};
514 return {getTrailingObjects<concepts::Requirement *>(), NumRequirements};
521 &&
"isSatisfied called on a dependent RequiresExpr");
553 #endif // LLVM_CLANG_AST_EXPRCONCEPTS_H ConceptSpecializationExpr(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten, ArrayRef< TemplateArgument > ConvertedArgs, const ConstraintSatisfaction *Satisfaction)
Defines the clang::ASTContext interface.
A requires-expression requirement which queries the validity and properties of an expression ('simple...
ArrayRef< ParmVarDecl * > getLocalParameters() const
Stmt - This represents one statement.
static bool classof(const Stmt *T)
C Language Family Type Representation.
Defines the C++ template declaration subclasses.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
llvm::iterator_range< child_iterator > child_range
SourceLocation getBeginLoc() const LLVM_READONLY
TypeRequirement(SubstitutionDiagnostic *Diagnostic)
Construct a type requirement when the nested name specifier is invalid due to a bad substitution...
A container of type source information.
void setSatisfied(bool IsSatisfied)
bool isSubstitutionFailure() const
bool isSatisfied() const
Whether or not the concept with the given arguments was satisfied when the expression was created...
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
ReturnTypeRequirement(SubstitutionDiagnostic *SubstDiag)
A return type requirement was specified but it was a substitution failure.
ASTConstraintSatisfaction * Satisfaction
Information about the satisfaction of the named concept with the given arguments. ...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Stores a list of template parameters for a TemplateDecl and its derived classes.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
NestedRequirement(Expr *Constraint)
SourceLocation getRequiresKWLoc() const
SatisfactionStatus getSatisfactionStatus() const
Expr * getConstraintExpr() const
unsigned NumTemplateArgs
The number of template arguments in the tail-allocated list of converted template arguments...
void setSatisfactionStatus(SatisfactionStatus Status)
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
NestedRequirement(SubstitutionDiagnostic *SubstDiag)
SourceLocation getEndLoc() const LLVM_READONLY
llvm::iterator_range< const_child_iterator > const_child_range
A requires-expression requirement which queries the existence of a type name or type template special...
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
ConstStmtIterator const_child_iterator
This represents one expression.
ConceptSpecializationExpr * getReturnTypeRequirementSubstitutedConstraintExpr() const
Represents the body of a requires-expression.
const_child_range children() const
bool hasNoexceptRequirement() const
bool containsUnexpandedParameterPack() const
bool isSubstitutionFailure() const
Requirement(RequirementKind Kind, bool IsDependent, bool ContainsUnexpandedParameterPack, bool IsSatisfied=true)
SatisfactionStatus getSatisfactionStatus() const
bool isTypeConstraint() const
TypeSourceInfo * getType() const
bool isSatisfied() const
Whether or not the requires clause is satisfied.
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
TemplateParameterList * getTypeConstraintTemplateParameterList() const
NamedDecl * FoundDecl
The declaration found by name lookup when the expression was created.
ArrayRef< concepts::Requirement * > getRequirements() const
StringRef SubstitutedEntity
SourceLocation TemplateKWLoc
The location of the template keyword, if specified when naming the concept.
static bool classof(const Stmt *T)
SourceLocation getEndLoc() const LLVM_READONLY
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
Encodes a location in the source.
void setContainsUnexpandedParameterPack(bool Contains)
static bool classof(const Requirement *R)
Common data class for constructs that reference concepts with template arguments. ...
std::pair< SourceLocation, std::string > SubstitutionDiagnostic
SourceLocation getNoexceptLoc() const
const_child_range children() const
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
NestedRequirement(ASTContext &C, Expr *Constraint, const ConstraintSatisfaction &Satisfaction)
SourceLocation getRBraceLoc() const
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
DeclarationNameInfo ConceptName
The concept name used.
SourceLocation getBeginLoc() const LLVM_READONLY
A static requirement that can be used in a requires-expression to check properties of types and expre...
static ConceptSpecializationExpr * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten, ArrayRef< TemplateArgument > ConvertedArgs, const ConstraintSatisfaction *Satisfaction)
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
const ASTConstraintSatisfaction & getSatisfaction() const
Get elaborated satisfaction info about the template arguments' satisfaction of the named concept...
RequiresExprBodyDecl * getBody() const
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
static bool classof(const Requirement *R)
StmtClass getStmtClass() const
ReturnTypeRequirement()
No return type requirement was specified.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
bool isExprSubstitutionFailure() const
void setDependent(bool IsDependent)
RequiresExprBitfields RequiresExprBits
static bool classof(const Requirement *R)
bool containsUnexpandedParameterPack() const
bool isSubstitutionFailure() const
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
ConceptDecl * NamedConcept
The concept named.
void setTemplateArguments(ArrayRef< TemplateArgument > Converted)
Set new template arguments for this concept specialization.
Defines the clang::SourceLocation class and associated facilities.
ArrayRef< TemplateArgument > getTemplateArguments() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
RequirementKind getKind() const
Represents the specialization of a concept - evaluates to a prvalue of type bool. ...
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
static Decl::Kind getKind(const Decl *D)
const ASTTemplateArgumentListInfo * ArgsAsWritten
The template argument list source info used to specialize the concept.
This represents a decl that may have a name.
This file provides AST data structures related to concepts.
const ReturnTypeRequirement & getReturnTypeRequirement() const