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;
158 bool ContainsUnexpandedParameterPack : 1;
171 bool ContainsUnexpandedParameterPack,
bool IsSatisfied =
true) :
173 ContainsUnexpandedParameterPack(ContainsUnexpandedParameterPack),
174 Satisfied(IsSatisfied) {}
180 "isSatisfied can only be called on non-dependent requirements.");
186 "setSatisfied can only be called on non-dependent requirements.");
187 Satisfied = IsSatisfied;
194 ContainsUnexpandedParameterPack = Contains;
197 return ContainsUnexpandedParameterPack;
211 llvm::PointerUnion<SubstitutionDiagnostic *, TypeSourceInfo *>
Value;
231 this->Status = Status;
240 "Attempted to get substitution diagnostic when there has been no " 241 "substitution failure.");
247 "Attempted to get type when there has been a substitution failure.");
269 llvm::PointerIntPair<
270 llvm::PointerUnion<TemplateParameterList *, SubstitutionDiagnostic *>,
283 TypeConstraintInfo(SubstDiag, 0) {}
294 return TypeConstraintInfo.getInt();
305 return TypeConstraintInfo.getPointer().isNull();
310 TypeConstraintInfo.getPointer().is<SubstitutionDiagnostic *>();
320 return TypeConstraintInfo.getPointer().get<SubstitutionDiagnostic *>();
331 llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>
Value;
333 ReturnTypeRequirement TypeReq;
383 return SubstitutedConstraintExpr;
388 "Attempted to get expression substitution diagnostic when there has " 389 "been no expression substitution failure");
390 return Value.get<SubstitutionDiagnostic *>();
395 "ExprRequirement has no expression because there has been a " 396 "substitution failure.");
408 llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>
Value;
425 "Nested requirement with non-dependent constraint must be " 426 "constructed with a ConstraintSatisfaction object");
433 Satisfaction.IsSatisfied),
443 "getSubstitutionDiagnostic() may not be called when there was no " 444 "substitution failure.");
450 "on nested requirements with " 451 "substitution failures.");
457 "called on nested requirements with " 458 "substitution failures.");
459 return *Satisfaction;
477 concepts::Requirement *> {
478 friend TrailingObjects;
481 unsigned NumLocalParameters;
482 unsigned NumRequirements;
486 unsigned numTrailingObjects(OverloadToken<ParmVarDecl *>)
const {
487 return NumLocalParameters;
490 unsigned numTrailingObjects(OverloadToken<concepts::Requirement *>)
const {
491 return NumRequirements;
494 RequiresExpr(ASTContext &
C, SourceLocation RequiresKWLoc,
495 RequiresExprBodyDecl *Body,
496 ArrayRef<ParmVarDecl *> LocalParameters,
497 ArrayRef<concepts::Requirement *> Requirements,
498 SourceLocation RBraceLoc);
499 RequiresExpr(ASTContext &
C, EmptyShell Empty,
unsigned NumLocalParameters,
500 unsigned NumRequirements);
503 static RequiresExpr *
504 Create(ASTContext &
C, SourceLocation RequiresKWLoc,
505 RequiresExprBodyDecl *Body, ArrayRef<ParmVarDecl *> LocalParameters,
506 ArrayRef<concepts::Requirement *> Requirements,
507 SourceLocation RBraceLoc);
508 static RequiresExpr *
509 Create(ASTContext &
C, EmptyShell Empty,
unsigned NumLocalParameters,
510 unsigned NumRequirements);
513 return {getTrailingObjects<ParmVarDecl *>(), NumLocalParameters};
519 return {getTrailingObjects<concepts::Requirement *>(), NumRequirements};
526 &&
"isSatisfied called on a dependent RequiresExpr");
558 #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 getEndLoc() const LLVM_READONLY
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
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, ArrayRef< ParmVarDecl * > LocalParameters, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
ReturnTypeRequirement(SubstitutionDiagnostic *SubstDiag)
A return type requirement was specified but it was a substitution failure.
ExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc, ReturnTypeRequirement Req, SatisfactionStatus Status, ConceptSpecializationExpr *SubstitutedConstraintExpr=nullptr)
Construct a compound requirement.
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.
Encodes a location in the source.
void setContainsUnexpandedParameterPack(bool Contains)
static bool classof(const Requirement *R)
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
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
Determines whether the value of this expression depends on.
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.
bool containsUnexpandedParameterPack() const
Determine whether this template parameter list contains an unexpanded parameter pack.
Declaration of a C++2a concept.
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
TypeRequirement(TypeSourceInfo *T)
Construct a type requirement from a type.
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.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
const ASTTemplateArgumentListInfo * ArgsAsWritten
The template argument list source info used to specialize the concept.
This represents a decl that may have a name.
const TypeConstraint * getTypeConstraint() const
This file provides AST data structures related to concepts.
const ReturnTypeRequirement & getReturnTypeRequirement() const