Go to the documentation of this file.
14 #ifndef LLVM_CLANG_AST_EXPRCONCEPTS_H
15 #define LLVM_CLANG_AST_EXPRCONCEPTS_H
27 #include "llvm/Support/TrailingObjects.h"
41 private llvm::TrailingObjects<ConceptSpecializationExpr,
44 friend TrailingObjects;
70 bool ContainsUnexpandedParameterPack);
89 bool ContainsUnexpandedParameterPack);
107 &&
"isSatisfied called on a dependent ConceptSpecializationExpr");
116 &&
"getSatisfaction called on dependent ConceptSpecializationExpr");
121 return T->
getStmtClass() == ConceptSpecializationExprClass;
126 return QualifierLoc.getBeginLoc();
160 bool ContainsUnexpandedParameterPack : 1;
173 bool ContainsUnexpandedParameterPack,
bool IsSatisfied =
true) :
174 Kind(Kind), Dependent(IsDependent),
175 ContainsUnexpandedParameterPack(ContainsUnexpandedParameterPack),
176 Satisfied(IsSatisfied) {}
182 "isSatisfied can only be called on non-dependent requirements.");
188 "setSatisfied can only be called on non-dependent requirements.");
189 Satisfied = IsSatisfied;
196 ContainsUnexpandedParameterPack = Contains;
199 return ContainsUnexpandedParameterPack;
213 llvm::PointerUnion<SubstitutionDiagnostic *, TypeSourceInfo *>
Value;
233 this->Status = Status;
242 "Attempted to get substitution diagnostic when there has been no "
243 "substitution failure.");
249 "Attempted to get type when there has been a substitution failure.");
271 llvm::PointerIntPair<
272 llvm::PointerUnion<TemplateParameterList *, SubstitutionDiagnostic *>,
285 TypeConstraintInfo(SubstDiag,
false) {}
296 return TypeConstraintInfo.getInt();
307 return TypeConstraintInfo.getPointer().isNull();
312 TypeConstraintInfo.getPointer().is<SubstitutionDiagnostic *>();
322 return TypeConstraintInfo.getPointer().get<SubstitutionDiagnostic *>();
333 llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>
Value;
335 ReturnTypeRequirement TypeReq;
385 return SubstitutedConstraintExpr;
390 "Attempted to get expression substitution diagnostic when there has "
391 "been no expression substitution failure");
392 return Value.get<SubstitutionDiagnostic *>();
397 "ExprRequirement has no expression because there has been a "
398 "substitution failure.");
410 llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>
Value;
427 "Nested requirement with non-dependent constraint must be "
428 "constructed with a ConstraintSatisfaction object");
435 Satisfaction.IsSatisfied),
440 return Value.is<SubstitutionDiagnostic *>();
445 "getSubstitutionDiagnostic() may not be called when there was no "
446 "substitution failure.");
447 return Value.get<SubstitutionDiagnostic *>();
452 "on nested requirements with "
453 "substitution failures.");
459 "called on nested requirements with "
460 "substitution failures.");
461 return *Satisfaction;
478 llvm::TrailingObjects<RequiresExpr, ParmVarDecl *,
479 concepts::Requirement *> {
480 friend TrailingObjects;
483 unsigned NumLocalParameters;
484 unsigned NumRequirements;
488 unsigned numTrailingObjects(OverloadToken<ParmVarDecl *>)
const {
489 return NumLocalParameters;
492 unsigned numTrailingObjects(OverloadToken<concepts::Requirement *>)
const {
493 return NumRequirements;
496 RequiresExpr(ASTContext &
C, SourceLocation RequiresKWLoc,
497 RequiresExprBodyDecl *Body,
498 ArrayRef<ParmVarDecl *> LocalParameters,
499 ArrayRef<concepts::Requirement *> Requirements,
500 SourceLocation RBraceLoc);
501 RequiresExpr(ASTContext &
C, EmptyShell Empty,
unsigned NumLocalParameters,
502 unsigned NumRequirements);
505 static RequiresExpr *
506 Create(ASTContext &
C, SourceLocation RequiresKWLoc,
507 RequiresExprBodyDecl *Body, ArrayRef<ParmVarDecl *> LocalParameters,
508 ArrayRef<concepts::Requirement *> Requirements,
509 SourceLocation RBraceLoc);
510 static RequiresExpr *
511 Create(ASTContext &
C, EmptyShell Empty,
unsigned NumLocalParameters,
512 unsigned NumRequirements);
515 return {getTrailingObjects<ParmVarDecl *>(), NumLocalParameters};
521 return {getTrailingObjects<concepts::Requirement *>(), NumRequirements};
528 &&
"isSatisfied called on a dependent RequiresExpr");
560 #endif // LLVM_CLANG_AST_EXPRCONCEPTS_H
TypeRequirement(TypeSourceInfo *T)
Construct a type requirement from a type.
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
const TypeConstraint * getTypeConstraint() const
SourceLocation getRequiresKWLoc() const
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
ArrayRef< concepts::Requirement * > getRequirements() const
Encodes a location in the source.
This represents a decl that may have a name.
SourceLocation getEndLoc() const LLVM_READONLY
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
void setTemplateArguments(ArrayRef< TemplateArgument > Converted)
Set new template arguments for this concept specialization.
bool isTypeConstraint() const
unsigned NumTemplateArgs
The number of template arguments in the tail-allocated list of converted template arguments.
SatisfactionStatus getSatisfactionStatus() const
ConceptSpecializationExpr * getReturnTypeRequirementSubstitutedConstraintExpr() const
bool containsUnexpandedParameterPack() const
ASTConstraintSatisfaction * Satisfaction
Information about the satisfaction of the named concept with the given arguments.
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, ArrayRef< ParmVarDecl * > LocalParameters, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
bool isSatisfied() const
Whether or not the requires clause is satisfied.
ReturnTypeRequirement(SubstitutionDiagnostic *SubstDiag)
A return type requirement was specified but it was a substitution failure.
NestedRequirement(Expr *Constraint)
ReturnTypeRequirement()
No return type requirement was specified.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
StringRef SubstitutedEntity
static bool classof(const Requirement *R)
bool isSubstitutionFailure() const
Expr * getConstraintExpr() const
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
Represents the body of a requires-expression.
void setSatisfactionStatus(SatisfactionStatus Status)
@ SS_TypeRequirementSubstitutionFailure
Declaration of a C++2a concept.
DeclarationNameInfo ConceptName
The concept name used.
Represents the specialization of a concept - evaluates to a prvalue of type bool.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void setSatisfied(bool IsSatisfied)
SourceLocation getRBraceLoc() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
ConceptDecl * NamedConcept
The concept named.
RequiresExprBodyDecl * getBody() const
A static requirement that can be used in a requires-expression to check properties of types and expre...
SourceLocation getEndLoc() const LLVM_READONLY
TypeRequirement(SubstitutionDiagnostic *Diagnostic)
Construct a type requirement when the nested name specifier is invalid due to a bad substitution.
RequiresExprBitfields RequiresExprBits
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
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)
SourceLocation getEndLoc() const LLVM_READONLY
Stores a list of template parameters for a TemplateDecl and its derived classes.
const_child_range children() const
A C++ nested-name-specifier augmented with source location information.
static bool classof(const Requirement *R)
ArrayRef< ParmVarDecl * > getLocalParameters() const
llvm::iterator_range< child_iterator > child_range
This file provides AST data structures related to concepts.
bool hasNoexceptRequirement() const
std::pair< SourceLocation, std::string > SubstitutionDiagnostic
bool isSubstitutionFailure() const
NestedRequirement(SubstitutionDiagnostic *SubstDiag)
const ASTTemplateArgumentListInfo * ArgsAsWritten
The template argument list source info used to specialize the concept.
static bool classof(const Requirement *R)
llvm::iterator_range< const_child_iterator > const_child_range
SourceLocation getBeginLoc() const LLVM_READONLY
SatisfactionStatus getSatisfactionStatus() const
ExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc, ReturnTypeRequirement Req, SatisfactionStatus Status, ConceptSpecializationExpr *SubstitutedConstraintExpr=nullptr)
Construct a compound requirement.
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
void setDependent(bool IsDependent)
StmtClass getStmtClass() const
SourceLocation getBeginLoc() const LLVM_READONLY
A requires-expression requirement which queries the existence of a type name or type template special...
Common data class for constructs that reference concepts with template arguments.
static bool classof(const Stmt *T)
TemplateParameterList * getTypeConstraintTemplateParameterList() const
TypeSourceInfo * getType() const
@ SS_ExprSubstitutionFailure
bool isValueDependent() const
Determines whether the value of this expression depends on.
ConstStmtIterator const_child_iterator
const_child_range children() const
ArrayRef< TemplateArgument > getTemplateArguments() const
const ASTConstraintSatisfaction & getSatisfaction() const
Get elaborated satisfaction info about the template arguments' satisfaction of the named concept.
Stmt - This represents one statement.
void setContainsUnexpandedParameterPack(bool Contains)
static bool classof(const Stmt *T)
bool isValid() const
Return true if this is a valid SourceLocation object.
A container of type source information.
SourceLocation getNoexceptLoc() const
ConceptSpecializationExpr(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten, ArrayRef< TemplateArgument > ConvertedArgs, const ConstraintSatisfaction *Satisfaction)
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
Requirement(RequirementKind Kind, bool IsDependent, bool ContainsUnexpandedParameterPack, bool IsSatisfied=true)
RequirementKind getKind() const
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
bool containsUnexpandedParameterPack() const
Determine whether this template parameter list contains an unexpanded parameter pack.
NamedDecl * FoundDecl
The declaration found by name lookup when the expression was created.
This represents one expression.
A requires-expression requirement which queries the validity and properties of an expression ('simple...
bool isSubstitutionFailure() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
NestedRequirement(ASTContext &C, Expr *Constraint, const ConstraintSatisfaction &Satisfaction)
bool isExprSubstitutionFailure() const
bool isSatisfied() const
Whether or not the concept with the given arguments was satisfied when the expression was created.
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceLocation TemplateKWLoc
The location of the template keyword, if specified when naming the concept.
const ReturnTypeRequirement & getReturnTypeRequirement() const
@ SS_ConstraintsNotSatisfied
bool containsUnexpandedParameterPack() const