14#ifndef LLVM_CLANG_AST_EXPRCONCEPTS_H
15#define LLVM_CLANG_AST_EXPRCONCEPTS_H
27#include "llvm/ADT/STLFunctionalExtras.h"
28#include "llvm/Support/ErrorHandling.h"
29#include "llvm/Support/TrailingObjects.h"
42class ConceptSpecializationExpr final :
public Expr {
66 bool ContainsUnexpandedParameterPack);
70 static ConceptSpecializationExpr *
75 static ConceptSpecializationExpr *
79 bool ContainsUnexpandedParameterPack);
82 return SpecDecl->getTemplateArguments();
96 return ConceptRef->hasExplicitTemplateArgs();
100 return ConceptRef->getConceptNameLoc();
103 return ConceptRef->getTemplateArgsAsWritten();
107 return ConceptRef->getNestedNameSpecifierLoc();
111 return ConceptRef->getTemplateKWLoc();
117 return ConceptRef->getConceptNameInfo();
121 assert(SpecDecl &&
"Template Argument Decl not initialized");
130 "isSatisfied called on a dependent ConceptSpecializationExpr");
131 return Satisfaction->IsSatisfied;
139 "getSatisfaction called on dependent ConceptSpecializationExpr");
140 return *Satisfaction;
144 return T->getStmtClass() == ConceptSpecializationExprClass;
148 return ConceptRef->getBeginLoc();
152 return ConceptRef->getEndLoc();
156 return ConceptRef->getLocation();
180 LLVM_PREFERRED_TYPE(
bool)
182 LLVM_PREFERRED_TYPE(
bool)
183 bool ContainsUnexpandedParameterPack : 1;
184 LLVM_PREFERRED_TYPE(
bool)
197 bool ContainsUnexpandedParameterPack,
bool IsSatisfied =
true) :
198 Kind(Kind), Dependent(IsDependent),
199 ContainsUnexpandedParameterPack(ContainsUnexpandedParameterPack),
200 Satisfied(IsSatisfied) {}
206 "isSatisfied can only be called on non-dependent requirements.");
212 "setSatisfied can only be called on non-dependent requirements.");
213 Satisfied = IsSatisfied;
220 ContainsUnexpandedParameterPack = Contains;
223 return ContainsUnexpandedParameterPack;
237 llvm::PointerUnion<SubstitutionDiagnostic *, TypeSourceInfo *>
Value;
238 SatisfactionStatus Status;
257 this->Status = Status;
266 "Attempted to get substitution diagnostic when there has been no "
267 "substitution failure.");
273 "Attempted to get type when there has been a substitution failure.");
278 return R->getKind() ==
RK_Type;
295 llvm::PointerIntPair<
296 llvm::PointerUnion<TemplateParameterList *, SubstitutionDiagnostic *>,
309 TypeConstraintInfo(SubstDiag,
false) {}
321 return TypeConstraintInfo.getInt();
332 return TypeConstraintInfo.getPointer().isNull();
358 llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>
Value;
360 ReturnTypeRequirement TypeReq;
362 SatisfactionStatus Status;
410 return SubstitutedConstraintExpr;
415 "Attempted to get expression substitution diagnostic when there has "
416 "been no expression substitution failure");
422 "ExprRequirement has no expression because there has been a "
423 "substitution failure.");
435 Expr *Constraint =
nullptr;
437 bool HasInvalidConstraint =
false;
438 StringRef InvalidConstraintEntity;
447 Constraint(Constraint) {
448 assert(Constraint->isInstantiationDependent() &&
449 "Nested requirement with non-dependent constraint must be "
450 "constructed with a ConstraintSatisfaction object");
457 Satisfaction.IsSatisfied),
458 Constraint(Constraint),
466 Satisfaction->IsSatisfied),
467 Satisfaction(Satisfaction), HasInvalidConstraint(
true),
468 InvalidConstraintEntity(InvalidConstraintEntity) {}
479 return InvalidConstraintEntity;
484 "getConstraintExpr() may not be called "
485 "on nested requirements with invalid constraint.");
490 return *Satisfaction;
505class RequiresExpr final :
public Expr,
506 llvm::TrailingObjects<RequiresExpr, ParmVarDecl *,
507 concepts::Requirement *> {
508 friend TrailingObjects;
511 unsigned NumLocalParameters;
512 unsigned NumRequirements;
518 unsigned numTrailingObjects(OverloadToken<ParmVarDecl *>)
const {
519 return NumLocalParameters;
529 unsigned NumRequirements);
541 unsigned NumRequirements);
544 return getTrailingObjects<ParmVarDecl *>(NumLocalParameters);
550 return getTrailingObjects<concepts::Requirement *>(NumRequirements);
557 &&
"isSatisfied called on a dependent RequiresExpr");
563 "setSatisfied called on a dependent RequiresExpr");
576 return T->getStmtClass() == RequiresExprClass;
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 ...
Declaration of a C++20 concept.
A reference to a concept and its template args, as it appears in the code.
Represents the specialization of a concept - evaluates to a prvalue of type bool.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getExprLoc() 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
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
NamedDecl * getFoundDecl() const
bool hasExplicitTemplateArgs() const
ConceptDecl * getConceptDecl() const
static bool classof(const Stmt *T)
ConceptReference * getConceptReference() const
TemplateName getNamedConcept() const
SourceLocation getConceptNameLoc() const
const ImplicitConceptSpecializationDecl * getSpecializationDecl() const
friend class ASTStmtReader
const DeclarationNameInfo & getConceptNameInfo() const
const ASTConstraintSatisfaction & getSatisfaction() const
Get elaborated satisfaction info about the template arguments' satisfaction of the named concept.
SourceLocation getTemplateKWLoc() const
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 a...
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
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...
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
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
friend class ASTStmtReader
Encodes a location in the source.
Stmt - This represents one statement.
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
llvm::iterator_range< child_iterator > child_range
RequiresExprBitfields RequiresExprBits
ConstStmtIterator const_child_iterator
llvm::iterator_range< const_child_iterator > const_child_range
Represents a C++ template name within the type system.
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.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
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.
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)
ExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc, ReturnTypeRequirement Req, SatisfactionStatus Status, ConceptSpecializationExpr *SubstitutedConstraintExpr=nullptr)
Construct a compound requirement.
bool hasNoexceptRequirement() const
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)
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)
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
TypeRequirement(TypeSourceInfo *T)
Construct a type requirement from a type.
void setSatisfactionStatus(SatisfactionStatus Status)
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
const FunctionProtoType * T
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, 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.
U cast(CodeGen::Address addr)
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>".
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
StringRef SubstitutedEntity