14#ifndef LLVM_CLANG_AST_EXPRCONCEPTS_H
15#define LLVM_CLANG_AST_EXPRCONCEPTS_H
27#include "llvm/Support/ErrorHandling.h"
28#include "llvm/Support/TrailingObjects.h"
71 bool ContainsUnexpandedParameterPack);
88 bool ContainsUnexpandedParameterPack);
95 assert(
SpecDecl &&
"Template Argument Decl not initialized");
104 "isSatisfied called on a dependent ConceptSpecializationExpr");
113 "getSatisfaction called on dependent ConceptSpecializationExpr");
118 return T->
getStmtClass() == ConceptSpecializationExprClass;
123 return QualifierLoc.getBeginLoc();
157 bool ContainsUnexpandedParameterPack : 1;
170 bool ContainsUnexpandedParameterPack,
bool IsSatisfied =
true) :
171 Kind(Kind), Dependent(IsDependent),
172 ContainsUnexpandedParameterPack(ContainsUnexpandedParameterPack),
173 Satisfied(IsSatisfied) {}
179 "isSatisfied can only be called on non-dependent requirements.");
185 "setSatisfied can only be called on non-dependent requirements.");
186 Satisfied = IsSatisfied;
193 ContainsUnexpandedParameterPack = Contains;
196 return ContainsUnexpandedParameterPack;
210 llvm::PointerUnion<SubstitutionDiagnostic *, TypeSourceInfo *>
Value;
230 this->Status = Status;
239 "Attempted to get substitution diagnostic when there has been no "
240 "substitution failure.");
246 "Attempted to get type when there has been a substitution failure.");
268 llvm::PointerIntPair<
269 llvm::PointerUnion<TemplateParameterList *, SubstitutionDiagnostic *>,
282 TypeConstraintInfo(SubstDiag,
false) {}
293 return TypeConstraintInfo.getInt();
304 return TypeConstraintInfo.getPointer().isNull();
330 llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>
Value;
332 ReturnTypeRequirement TypeReq;
382 return SubstitutedConstraintExpr;
387 "Attempted to get expression substitution diagnostic when there has "
388 "been no expression substitution failure");
394 "ExprRequirement has no expression because there has been a "
395 "substitution failure.");
407 Expr *Constraint =
nullptr;
409 bool HasInvalidConstraint =
false;
410 StringRef InvalidConstraintEntity;
419 Constraint(Constraint) {
421 "Nested requirement with non-dependent constraint must be "
422 "constructed with a ConstraintSatisfaction object");
429 Satisfaction.IsSatisfied),
430 Constraint(Constraint),
438 Satisfaction->IsSatisfied),
439 Satisfaction(Satisfaction), HasInvalidConstraint(
true),
440 InvalidConstraintEntity(InvalidConstraintEntity) {}
451 return InvalidConstraintEntity;
456 "getConstraintExpr() may not be called "
457 "on nested requirements with invalid constraint.");
462 return *Satisfaction;
479 llvm::TrailingObjects<RequiresExpr, ParmVarDecl *,
480 concepts::Requirement *> {
481 friend TrailingObjects;
484 unsigned NumLocalParameters;
485 unsigned NumRequirements;
489 unsigned numTrailingObjects(OverloadToken<ParmVarDecl *>)
const {
490 return NumLocalParameters;
493 unsigned numTrailingObjects(OverloadToken<concepts::Requirement *>)
const {
494 return NumRequirements;
497 RequiresExpr(ASTContext &
C, SourceLocation RequiresKWLoc,
498 RequiresExprBodyDecl *Body,
499 ArrayRef<ParmVarDecl *> LocalParameters,
500 ArrayRef<concepts::Requirement *> Requirements,
501 SourceLocation RBraceLoc);
502 RequiresExpr(ASTContext &
C, EmptyShell Empty,
unsigned NumLocalParameters,
503 unsigned NumRequirements);
506 static RequiresExpr *
507 Create(ASTContext &
C, SourceLocation RequiresKWLoc,
508 RequiresExprBodyDecl *Body, ArrayRef<ParmVarDecl *> LocalParameters,
509 ArrayRef<concepts::Requirement *> Requirements,
510 SourceLocation RBraceLoc);
511 static RequiresExpr *
512 Create(ASTContext &
C, EmptyShell Empty,
unsigned NumLocalParameters,
513 unsigned NumRequirements);
516 return {getTrailingObjects<ParmVarDecl *>(), NumLocalParameters};
522 return {getTrailingObjects<concepts::Requirement *>(), NumRequirements};
529 &&
"isSatisfied called on a dependent RequiresExpr");
535 "setSatisfied called on a dependent RequiresExpr");
This file provides AST data structures related to concepts.
Defines the clang::ASTContext interface.
Defines the C++ template declaration subclasses.
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 ...
Reads an AST files chain containing the contents of a translation unit.
Declaration of a C++20 concept.
Common data class for constructs that reference concepts with template arguments.
DeclarationNameInfo ConceptName
The concept name used.
ConceptDecl * NamedConcept
The concept named.
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
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.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
const_child_range children() const
bool isSatisfied() const
Whether or not the concept with the given arguments was satisfied when the expression was created.
ArrayRef< TemplateArgument > getTemplateArguments() const
std::pair< SourceLocation, std::string > SubstitutionDiagnostic
ASTConstraintSatisfaction * Satisfaction
Information about the satisfaction of the named concept with the given arguments.
static bool classof(const Stmt *T)
static ConceptSpecializationExpr * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
const ImplicitConceptSpecializationDecl * getSpecializationDecl() const
const ASTConstraintSatisfaction & getSatisfaction() const
Get elaborated satisfaction info about the template arguments' satisfaction of the named concept.
ImplicitConceptSpecializationDecl * SpecDecl
The Implicit Concept Specialization Decl, which holds the template arguments for this specialization.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
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.
ArrayRef< TemplateArgument > getTemplateArguments() const
This represents a decl that may have a name.
A C++ nested-name-specifier augmented with source location information.
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)
SourceLocation getRBraceLoc() const
void setSatisfied(bool IsSatisfied)
SourceLocation getRequiresKWLoc() const
SourceLocation getEndLoc() const LLVM_READONLY
const_child_range children() const
RequiresExprBodyDecl * getBody() const
ArrayRef< concepts::Requirement * > getRequirements() const
bool isSatisfied() const
Whether or not the requires clause is satisfied.
SourceLocation getBeginLoc() const LLVM_READONLY
static bool classof(const Stmt *T)
ArrayRef< ParmVarDecl * > getLocalParameters() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
Stmt - This represents one statement.
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
StmtClass getStmtClass() const
llvm::iterator_range< child_iterator > child_range
RequiresExprBitfields RequiresExprBits
ConstStmtIterator const_child_iterator
llvm::iterator_range< const_child_iterator > const_child_range
Stores a list of template parameters for a TemplateDecl and its derived classes.
bool containsUnexpandedParameterPack() const
Determine whether this template parameter list contains an unexpanded parameter pack.
A container of type source information.
ReturnTypeRequirement()
No return type requirement was specified.
bool containsUnexpandedParameterPack() const
bool isTypeConstraint() const
TemplateParameterList * getTypeConstraintTemplateParameterList() const
const TypeConstraint * getTypeConstraint() const
bool isSubstitutionFailure() const
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
ReturnTypeRequirement(SubstitutionDiagnostic *SubstDiag)
A return type requirement was specified but it was a substitution failure.
A requires-expression requirement which queries the validity and properties of an expression ('simple...
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
ConceptSpecializationExpr * getReturnTypeRequirementSubstitutedConstraintExpr() const
bool isExprSubstitutionFailure() const
@ SS_ConstraintsNotSatisfied
@ SS_TypeRequirementSubstitutionFailure
@ SS_ExprSubstitutionFailure
const ReturnTypeRequirement & getReturnTypeRequirement() const
SatisfactionStatus getSatisfactionStatus() const
SourceLocation getNoexceptLoc() const
static bool classof(const Requirement *R)
bool hasNoexceptRequirement() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
NestedRequirement(StringRef InvalidConstraintEntity, const ASTConstraintSatisfaction *Satisfaction)
static bool classof(const Requirement *R)
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
bool hasInvalidConstraint() const
Expr * getConstraintExpr() const
NestedRequirement(ASTContext &C, StringRef InvalidConstraintEntity, const ConstraintSatisfaction &Satisfaction)
StringRef getInvalidConstraintEntity()
NestedRequirement(ASTContext &C, Expr *Constraint, const ConstraintSatisfaction &Satisfaction)
NestedRequirement(Expr *Constraint)
A static requirement that can be used in a requires-expression to check properties of types and expre...
void setSatisfied(bool IsSatisfied)
void setContainsUnexpandedParameterPack(bool Contains)
void setDependent(bool IsDependent)
RequirementKind getKind() const
bool containsUnexpandedParameterPack() const
Requirement(RequirementKind Kind, bool IsDependent, bool ContainsUnexpandedParameterPack, bool IsSatisfied=true)
A requires-expression requirement which queries the existence of a type name or type template special...
TypeRequirement(SubstitutionDiagnostic *Diagnostic)
Construct a type requirement when the nested name specifier is invalid due to a bad substitution.
static bool classof(const Requirement *R)
bool isSubstitutionFailure() const
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
TypeSourceInfo * getType() const
SatisfactionStatus getSatisfactionStatus() const
void setSatisfactionStatus(SatisfactionStatus Status)
@ C
Languages that the frontend can parse and compile.
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>".
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceLocation getEndLoc() const LLVM_READONLY
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
StringRef SubstitutedEntity