19#include "llvm/ADT/StringExtras.h"
27 if (
auto *
E = dyn_cast<Expr *>(Detail))
30 auto &SubstitutionDiagnostic =
31 *cast<std::pair<SourceLocation, StringRef> *>(Detail);
32 StringRef Message =
C.backupStr(SubstitutionDiagnostic.second);
33 auto *NewSubstDiag =
new (
C) std::pair<SourceLocation, StringRef>(
34 SubstitutionDiagnostic.first, Message);
41 : NumRecords{Satisfaction.Details.size()},
42 IsSatisfied{Satisfaction.IsSatisfied}, ContainsErrors{
43 Satisfaction.ContainsErrors} {
46 getTrailingObjects() + I);
51 : NumRecords{Satisfaction.NumRecords},
52 IsSatisfied{Satisfaction.IsSatisfied},
53 ContainsErrors{Satisfaction.ContainsErrors} {
56 getTrailingObjects() + I);
63 totalSizeToAlloc<UnsatisfiedConstraintRecord>(
72 totalSizeToAlloc<UnsatisfiedConstraintRecord>(Satisfaction.
NumRecords);
80 ID.AddPointer(ConstraintOwner);
81 ID.AddInteger(TemplateArgs.size());
82 for (
auto &Arg : TemplateArgs)
99 return QualifierLoc.getBeginLoc();
109 llvm::ListSeparator Sep(
", ");
113 ArgLoc.getArgument().print(Policy, OS,
false);
123 :
Requirement(IsSimple ? RK_Simple : RK_Compound, Status == SS_Dependent,
124 Status == SS_Dependent &&
125 (
E->containsUnexpandedParameterPack() ||
126 Req.containsUnexpandedParameterPack()),
127 Status == SS_Satisfied),
128 Value(
E), NoexceptLoc(NoexceptLoc), TypeReq(Req),
129 SubstitutedConstraintExpr(SubstitutedConstraintExpr), Status(Status) {
131 "Simple requirement must not have a return type requirement or a "
132 "noexcept specification");
140 :
Requirement(IsSimple ? RK_Simple : RK_Compound, Req.isDependent(),
141 Req.containsUnexpandedParameterPack(),
false),
142 Value(ExprSubstDiag), NoexceptLoc(NoexceptLoc), TypeReq(Req),
143 Status(SS_ExprSubstitutionFailure) {
145 "Simple requirement must not have a return type requirement or a "
146 "noexcept specification");
151 : TypeConstraintInfo(TPL,
false) {
152 assert(TPL->
size() == 1);
154 cast<TemplateTypeParmDecl>(TPL->
getParam(0))->getTypeConstraint();
156 "TPL must have a template type parameter with a type constraint");
160 Constraint->getTemplateArgsAsWritten() &&
162 Constraint->getTemplateArgsAsWritten()->arguments().drop_front(1));
163 TypeConstraintInfo.setInt(
Dependent ?
true :
false);
168 : TypeConstraintInfo(TPL, IsDependent) {}
178 Status(
T->getType()->isInstantiationDependentType() ?
SS_Dependent
static void CreateUnsatisfiedConstraintRecord(const ASTContext &C, const UnsatisfiedConstraintRecord &Detail, UnsatisfiedConstraintRecord *TrailingObject)
This file provides AST data structures related to concepts.
Defines the clang::ASTContext interface.
Defines Expressions and AST nodes for C++2a concepts.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A reference to a concept and its template args, as it appears in the code.
NestedNameSpecifierLoc NestedNameSpec
bool hasExplicitTemplateArgs() const
Whether or not template arguments were explicitly specified in the concept reference (they might not ...
DeclarationNameInfo ConceptName
The concept name used.
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
const DeclarationNameInfo & getConceptNameInfo() const
SourceLocation TemplateKWLoc
The location of the template keyword, if specified when naming the concept.
TemplateDecl * NamedConcept
The concept named.
SourceLocation getBeginLoc() const LLVM_READONLY
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.
void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
Represents the specialization of a concept - evaluates to a prvalue of type bool.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C)
llvm::SmallVector< Detail, 4 > Details
The substituted constraint expr, if the template arguments could be substituted into them,...
This represents one expression.
This represents a decl that may have a name.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false, bool PrintFinalScopeResOp=true) const
Print this nested name specifier to the given output stream.
Encodes a location in the source.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
static bool anyInstantiationDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args)
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
A container of type source information.
ReturnTypeRequirement()
No return type requirement was specified.
bool isTypeConstraint() const
@ SS_TypeRequirementSubstitutionFailure
ExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc, ReturnTypeRequirement Req, SatisfactionStatus Status, ConceptSpecializationExpr *SubstitutedConstraintExpr=nullptr)
Construct a compound requirement.
A static requirement that can be used in a requires-expression to check properties of types and expre...
bool containsUnexpandedParameterPack() const
TypeRequirement(TypeSourceInfo *T)
Construct a type requirement from a type.
The JSON file list parser is used to communicate input to InstallAPI.
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
llvm::PointerUnion< Expr *, std::pair< SourceLocation, StringRef > * > UnsatisfiedConstraintRecord
Pairs of unsatisfied atomic constraint expressions along with the substituted constraint expr,...
const FunctionProtoType * T
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
static ASTConstraintSatisfaction * Rebuild(const ASTContext &C, const ASTConstraintSatisfaction &Satisfaction)
ASTConstraintSatisfaction(const ASTContext &C, const ConstraintSatisfaction &Satisfaction)
const UnsatisfiedConstraintRecord * begin() const
static ASTConstraintSatisfaction * Create(const ASTContext &C, const ConstraintSatisfaction &Satisfaction)
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
ArrayRef< TemplateArgumentLoc > arguments() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
void printName(raw_ostream &OS, PrintingPolicy Policy) const
printName - Print the human-readable name to a stream.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
Describes how types, statements, expressions, and declarations should be printed.