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;
158 bool ContainsUnexpandedParameterPack : 1;
171 bool ContainsUnexpandedParameterPack,
bool IsSatisfied =
true) :
172 Kind(Kind), Dependent(IsDependent),
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();
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");
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),
438 return Value.is<SubstitutionDiagnostic *>();
443 "getSubstitutionDiagnostic() may not be called when there was no "
444 "substitution failure.");
445 return Value.get<SubstitutionDiagnostic *>();
450 "on nested requirements with "
451 "substitution failures.");
457 "called on nested requirements with "
458 "substitution failures.");
459 return *Satisfaction;
476 llvm::TrailingObjects<RequiresExpr, ParmVarDecl *,
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
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.
bool containsUnexpandedParameterPack() const
Determine whether this template parameter list contains an unexpanded parameter pack.
ConstStmtIterator const_child_iterator
const_child_range children() const
ArrayRef< TemplateArgument > getTemplateArguments() const
Dataflow Directional Tag Classes.
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...
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>".
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