clang  15.0.0git
ExprConcepts.h
Go to the documentation of this file.
1 //===- ExprConcepts.h - C++2a Concepts expressions --------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// Defines Expressions and AST nodes for C++2a concepts.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_AST_EXPRCONCEPTS_H
15 #define LLVM_CLANG_AST_EXPRCONCEPTS_H
16 
17 #include "clang/AST/ASTContext.h"
18 #include "clang/AST/ASTConcept.h"
19 #include "clang/AST/Decl.h"
21 #include "clang/AST/DeclTemplate.h"
22 #include "clang/AST/Expr.h"
24 #include "clang/AST/TemplateBase.h"
25 #include "clang/AST/Type.h"
27 #include "llvm/Support/TrailingObjects.h"
28 #include <utility>
29 #include <string>
30 
31 namespace clang {
32 class ASTStmtReader;
33 class ASTStmtWriter;
34 
35 /// \brief Represents the specialization of a concept - evaluates to a prvalue
36 /// of type bool.
37 ///
38 /// According to C++2a [expr.prim.id]p3 an id-expression that denotes the
39 /// specialization of a concept results in a prvalue of type bool.
40 class ConceptSpecializationExpr final : public Expr, public ConceptReference,
41  private llvm::TrailingObjects<ConceptSpecializationExpr,
42  TemplateArgument> {
43  friend class ASTStmtReader;
44  friend TrailingObjects;
45 public:
46  using SubstitutionDiagnostic = std::pair<SourceLocation, std::string>;
47 
48 protected:
49  /// \brief The number of template arguments in the tail-allocated list of
50  /// converted template arguments.
51  unsigned NumTemplateArgs;
52 
53  /// \brief Information about the satisfaction of the named concept with the
54  /// given arguments. If this expression is value dependent, this is to be
55  /// ignored.
57 
60  DeclarationNameInfo ConceptNameInfo,
63  ArrayRef<TemplateArgument> ConvertedArgs,
65 
67  ArrayRef<TemplateArgument> ConvertedArgs,
69  bool Dependent,
70  bool ContainsUnexpandedParameterPack);
71 
73 
74 public:
75 
81  ArrayRef<TemplateArgument> ConvertedArgs,
83 
86  ArrayRef<TemplateArgument> ConvertedArgs,
88  bool Dependent,
89  bool ContainsUnexpandedParameterPack);
90 
92  Create(ASTContext &C, EmptyShell Empty, unsigned NumTemplateArgs);
93 
95  return ArrayRef<TemplateArgument>(getTrailingObjects<TemplateArgument>(),
97  }
98 
99  /// \brief Set new template arguments for this concept specialization.
101 
102  /// \brief Whether or not the concept with the given arguments was satisfied
103  /// when the expression was created.
104  /// The expression must not be dependent.
105  bool isSatisfied() const {
106  assert(!isValueDependent()
107  && "isSatisfied called on a dependent ConceptSpecializationExpr");
108  return Satisfaction->IsSatisfied;
109  }
110 
111  /// \brief Get elaborated satisfaction info about the template arguments'
112  /// satisfaction of the named concept.
113  /// The expression must not be dependent.
115  assert(!isValueDependent()
116  && "getSatisfaction called on dependent ConceptSpecializationExpr");
117  return *Satisfaction;
118  }
119 
120  static bool classof(const Stmt *T) {
121  return T->getStmtClass() == ConceptSpecializationExprClass;
122  }
123 
124  SourceLocation getBeginLoc() const LLVM_READONLY {
125  if (auto QualifierLoc = getNestedNameSpecifierLoc())
126  return QualifierLoc.getBeginLoc();
127  return ConceptName.getBeginLoc();
128  }
129 
130  SourceLocation getEndLoc() const LLVM_READONLY {
131  // If the ConceptSpecializationExpr is the ImmediatelyDeclaredConstraint
132  // of a TypeConstraint written syntactically as a constrained-parameter,
133  // there may not be a template argument list.
136  }
137 
138  // Iterators
141  }
144  }
145 };
146 
147 namespace concepts {
148 
149 /// \brief A static requirement that can be used in a requires-expression to
150 /// check properties of types and expression.
151 class Requirement {
152 public:
153  // Note - simple and compound requirements are both represented by the same
154  // class (ExprRequirement).
156 private:
157  const RequirementKind Kind;
158  // FIXME: use RequirementDependence to model dependence?
159  bool Dependent : 1;
160  bool ContainsUnexpandedParameterPack : 1;
161  bool Satisfied : 1;
162 public:
164  StringRef SubstitutedEntity;
165  // FIXME: Store diagnostics semantically and not as prerendered strings.
166  // Fixing this probably requires serialization of PartialDiagnostic
167  // objects.
169  StringRef DiagMessage;
170  };
171 
172  Requirement(RequirementKind Kind, bool IsDependent,
173  bool ContainsUnexpandedParameterPack, bool IsSatisfied = true) :
174  Kind(Kind), Dependent(IsDependent),
175  ContainsUnexpandedParameterPack(ContainsUnexpandedParameterPack),
176  Satisfied(IsSatisfied) {}
177 
178  RequirementKind getKind() const { return Kind; }
179 
180  bool isSatisfied() const {
181  assert(!Dependent &&
182  "isSatisfied can only be called on non-dependent requirements.");
183  return Satisfied;
184  }
185 
186  void setSatisfied(bool IsSatisfied) {
187  assert(!Dependent &&
188  "setSatisfied can only be called on non-dependent requirements.");
189  Satisfied = IsSatisfied;
190  }
191 
192  void setDependent(bool IsDependent) { Dependent = IsDependent; }
193  bool isDependent() const { return Dependent; }
194 
196  ContainsUnexpandedParameterPack = Contains;
197  }
199  return ContainsUnexpandedParameterPack;
200  }
201 };
202 
203 /// \brief A requires-expression requirement which queries the existence of a
204 /// type name or type template specialization ('type' requirements).
205 class TypeRequirement : public Requirement {
206 public:
211  };
212 private:
213  llvm::PointerUnion<SubstitutionDiagnostic *, TypeSourceInfo *> Value;
214  SatisfactionStatus Status;
215 public:
218 
219  /// \brief Construct a type requirement from a type. If the given type is not
220  /// dependent, this indicates that the type exists and the requirement will be
221  /// satisfied. Otherwise, the SubstitutionDiagnostic constructor is to be
222  /// used.
224 
225  /// \brief Construct a type requirement when the nested name specifier is
226  /// invalid due to a bad substitution. The requirement is unsatisfied.
229  Status(SS_SubstitutionFailure) {}
230 
231  SatisfactionStatus getSatisfactionStatus() const { return Status; }
233  this->Status = Status;
234  }
235 
236  bool isSubstitutionFailure() const {
237  return Status == SS_SubstitutionFailure;
238  }
239 
241  assert(Status == SS_SubstitutionFailure &&
242  "Attempted to get substitution diagnostic when there has been no "
243  "substitution failure.");
244  return Value.get<SubstitutionDiagnostic *>();
245  }
246 
248  assert(!isSubstitutionFailure() &&
249  "Attempted to get type when there has been a substitution failure.");
250  return Value.get<TypeSourceInfo *>();
251  }
252 
253  static bool classof(const Requirement *R) {
254  return R->getKind() == RK_Type;
255  }
256 };
257 
258 /// \brief A requires-expression requirement which queries the validity and
259 /// properties of an expression ('simple' and 'compound' requirements).
260 class ExprRequirement : public Requirement {
261 public:
269  };
271  llvm::PointerIntPair<
272  llvm::PointerUnion<TemplateParameterList *, SubstitutionDiagnostic *>,
273  1, bool>
274  TypeConstraintInfo;
275  public:
278 
279  /// \brief No return type requirement was specified.
280  ReturnTypeRequirement() : TypeConstraintInfo(nullptr, false) {}
281 
282  /// \brief A return type requirement was specified but it was a
283  /// substitution failure.
284  ReturnTypeRequirement(SubstitutionDiagnostic *SubstDiag) :
285  TypeConstraintInfo(SubstDiag, false) {}
286 
287  /// \brief A 'type constraint' style return type requirement.
288  /// \param TPL an invented template parameter list containing a single
289  /// type parameter with a type-constraint.
290  // TODO: Can we maybe not save the whole template parameter list and just
291  // the type constraint? Saving the whole TPL makes it easier to handle in
292  // serialization but is less elegant.
294 
295  bool isDependent() const {
296  return TypeConstraintInfo.getInt();
297  }
298 
300  if (!isTypeConstraint())
301  return false;
304  }
305 
306  bool isEmpty() const {
307  return TypeConstraintInfo.getPointer().isNull();
308  }
309 
310  bool isSubstitutionFailure() const {
311  return !isEmpty() &&
312  TypeConstraintInfo.getPointer().is<SubstitutionDiagnostic *>();
313  }
314 
315  bool isTypeConstraint() const {
316  return !isEmpty() &&
317  TypeConstraintInfo.getPointer().is<TemplateParameterList *>();
318  }
319 
320  SubstitutionDiagnostic *getSubstitutionDiagnostic() const {
321  assert(isSubstitutionFailure());
322  return TypeConstraintInfo.getPointer().get<SubstitutionDiagnostic *>();
323  }
324 
325  const TypeConstraint *getTypeConstraint() const;
326 
328  assert(isTypeConstraint());
329  return TypeConstraintInfo.getPointer().get<TemplateParameterList *>();
330  }
331  };
332 private:
333  llvm::PointerUnion<Expr *, SubstitutionDiagnostic *> Value;
334  SourceLocation NoexceptLoc; // May be empty if noexcept wasn't specified.
335  ReturnTypeRequirement TypeReq;
336  ConceptSpecializationExpr *SubstitutedConstraintExpr;
337  SatisfactionStatus Status;
338 public:
341 
342  /// \brief Construct a compound requirement.
343  /// \param E the expression which is checked by this requirement.
344  /// \param IsSimple whether this was a simple requirement in source.
345  /// \param NoexceptLoc the location of the noexcept keyword, if it was
346  /// specified, otherwise an empty location.
347  /// \param Req the requirement for the type of the checked expression.
348  /// \param Status the satisfaction status of this requirement.
350  Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
352  ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr);
353 
354  /// \brief Construct a compound requirement whose expression was a
355  /// substitution failure. The requirement is not satisfied.
356  /// \param E the diagnostic emitted while instantiating the original
357  /// expression.
358  /// \param IsSimple whether this was a simple requirement in source.
359  /// \param NoexceptLoc the location of the noexcept keyword, if it was
360  /// specified, otherwise an empty location.
361  /// \param Req the requirement for the type of the checked expression (omit
362  /// if no requirement was specified).
363  ExprRequirement(SubstitutionDiagnostic *E, bool IsSimple,
364  SourceLocation NoexceptLoc, ReturnTypeRequirement Req = {});
365 
366  bool isSimple() const { return getKind() == RK_Simple; }
367  bool isCompound() const { return getKind() == RK_Compound; }
368 
369  bool hasNoexceptRequirement() const { return NoexceptLoc.isValid(); }
370  SourceLocation getNoexceptLoc() const { return NoexceptLoc; }
371 
372  SatisfactionStatus getSatisfactionStatus() const { return Status; }
373 
375  return Status == SS_ExprSubstitutionFailure;
376  }
377 
379  return TypeReq;
380  }
381 
384  assert(Status >= SS_TypeRequirementSubstitutionFailure);
385  return SubstitutedConstraintExpr;
386  }
387 
388  SubstitutionDiagnostic *getExprSubstitutionDiagnostic() const {
389  assert(isExprSubstitutionFailure() &&
390  "Attempted to get expression substitution diagnostic when there has "
391  "been no expression substitution failure");
392  return Value.get<SubstitutionDiagnostic *>();
393  }
394 
395  Expr *getExpr() const {
396  assert(!isExprSubstitutionFailure() &&
397  "ExprRequirement has no expression because there has been a "
398  "substitution failure.");
399  return Value.get<Expr *>();
400  }
401 
402  static bool classof(const Requirement *R) {
403  return R->getKind() == RK_Compound || R->getKind() == RK_Simple;
404  }
405 };
406 
407 /// \brief A requires-expression requirement which is satisfied when a general
408 /// constraint expression is satisfied ('nested' requirements).
410  llvm::PointerUnion<Expr *, SubstitutionDiagnostic *> Value;
411  const ASTConstraintSatisfaction *Satisfaction = nullptr;
412 
413 public:
416 
417  NestedRequirement(SubstitutionDiagnostic *SubstDiag) :
418  Requirement(RK_Nested, /*IsDependent=*/false,
419  /*ContainsUnexpandedParameterPack*/false,
420  /*IsSatisfied=*/false), Value(SubstDiag) {}
421 
422  NestedRequirement(Expr *Constraint) :
423  Requirement(RK_Nested, /*IsDependent=*/true,
424  Constraint->containsUnexpandedParameterPack()),
425  Value(Constraint) {
426  assert(Constraint->isInstantiationDependent() &&
427  "Nested requirement with non-dependent constraint must be "
428  "constructed with a ConstraintSatisfaction object");
429  }
430 
432  const ConstraintSatisfaction &Satisfaction) :
433  Requirement(RK_Nested, Constraint->isInstantiationDependent(),
434  Constraint->containsUnexpandedParameterPack(),
435  Satisfaction.IsSatisfied),
436  Value(Constraint),
437  Satisfaction(ASTConstraintSatisfaction::Create(C, Satisfaction)) {}
438 
439  bool isSubstitutionFailure() const {
440  return Value.is<SubstitutionDiagnostic *>();
441  }
442 
443  SubstitutionDiagnostic *getSubstitutionDiagnostic() const {
444  assert(isSubstitutionFailure() &&
445  "getSubstitutionDiagnostic() may not be called when there was no "
446  "substitution failure.");
447  return Value.get<SubstitutionDiagnostic *>();
448  }
449 
451  assert(!isSubstitutionFailure() && "getConstraintExpr() may not be called "
452  "on nested requirements with "
453  "substitution failures.");
454  return Value.get<Expr *>();
455  }
456 
458  assert(!isSubstitutionFailure() && "getConstraintSatisfaction() may not be "
459  "called on nested requirements with "
460  "substitution failures.");
461  return *Satisfaction;
462  }
463 
464  static bool classof(const Requirement *R) {
465  return R->getKind() == RK_Nested;
466  }
467 };
468 
469 } // namespace concepts
470 
471 /// C++2a [expr.prim.req]:
472 /// A requires-expression provides a concise way to express requirements on
473 /// template arguments. A requirement is one that can be checked by name
474 /// lookup (6.4) or by checking properties of types and expressions.
475 /// [...]
476 /// A requires-expression is a prvalue of type bool [...]
477 class RequiresExpr final : public Expr,
478  llvm::TrailingObjects<RequiresExpr, ParmVarDecl *,
479  concepts::Requirement *> {
480  friend TrailingObjects;
481  friend class ASTStmtReader;
482 
483  unsigned NumLocalParameters;
484  unsigned NumRequirements;
485  RequiresExprBodyDecl *Body;
486  SourceLocation RBraceLoc;
487 
488  unsigned numTrailingObjects(OverloadToken<ParmVarDecl *>) const {
489  return NumLocalParameters;
490  }
491 
492  unsigned numTrailingObjects(OverloadToken<concepts::Requirement *>) const {
493  return NumRequirements;
494  }
495 
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);
503 
504 public:
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);
513 
515  return {getTrailingObjects<ParmVarDecl *>(), NumLocalParameters};
516  }
517 
518  RequiresExprBodyDecl *getBody() const { return Body; }
519 
521  return {getTrailingObjects<concepts::Requirement *>(), NumRequirements};
522  }
523 
524  /// \brief Whether or not the requires clause is satisfied.
525  /// The expression must not be dependent.
526  bool isSatisfied() const {
527  assert(!isValueDependent()
528  && "isSatisfied called on a dependent RequiresExpr");
529  return RequiresExprBits.IsSatisfied;
530  }
531 
533  return RequiresExprBits.RequiresKWLoc;
534  }
535 
536  SourceLocation getRBraceLoc() const { return RBraceLoc; }
537 
538  static bool classof(const Stmt *T) {
539  return T->getStmtClass() == RequiresExprClass;
540  }
541 
542  SourceLocation getBeginLoc() const LLVM_READONLY {
543  return RequiresExprBits.RequiresKWLoc;
544  }
545  SourceLocation getEndLoc() const LLVM_READONLY {
546  return RBraceLoc;
547  }
548 
549  // Iterators
552  }
555  }
556 };
557 
558 } // namespace clang
559 
560 #endif // LLVM_CLANG_AST_EXPRCONCEPTS_H
clang::concepts::TypeRequirement::TypeRequirement
TypeRequirement(TypeSourceInfo *T)
Construct a type requirement from a type.
Definition: SemaConcept.cpp:1116
clang::concepts::Requirement::RequirementKind
RequirementKind
Definition: ExprConcepts.h:155
clang::concepts::ExprRequirement::getExprSubstitutionDiagnostic
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
Definition: ExprConcepts.h:388
clang::ASTConstraintSatisfaction
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition: ASTConcept.h:76
clang::concepts::Requirement::SubstitutionDiagnostic::DiagLoc
SourceLocation DiagLoc
Definition: ExprConcepts.h:168
clang::concepts::ExprRequirement::ReturnTypeRequirement::getTypeConstraint
const TypeConstraint * getTypeConstraint() const
Definition: ExprConcepts.cpp:136
clang::RequiresExpr::getRequiresKWLoc
SourceLocation getRequiresKWLoc() const
Definition: ExprConcepts.h:532
clang::concepts::TypeRequirement::getSubstitutionDiagnostic
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
Definition: ExprConcepts.h:240
clang::concepts::TypeRequirement::ASTStmtReader
friend ASTStmtReader
Definition: ExprConcepts.h:216
clang::RequiresExpr::getRequirements
ArrayRef< concepts::Requirement * > getRequirements() const
Definition: ExprConcepts.h:520
clang::concepts::TypeRequirement::SS_SubstitutionFailure
@ SS_SubstitutionFailure
Definition: ExprConcepts.h:209
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::concepts::ExprRequirement::ReturnTypeRequirement::isEmpty
bool isEmpty() const
Definition: ExprConcepts.h:306
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:55
clang::DeclarationNameInfo::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclarationName.h:876
clang::concepts::Requirement::SubstitutionDiagnostic
Definition: ExprConcepts.h:163
clang::RequiresExpr
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:477
clang::concepts::NestedRequirement::getSubstitutionDiagnostic
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
Definition: ExprConcepts.h:443
clang::ConceptSpecializationExpr::setTemplateArguments
void setTemplateArguments(ArrayRef< TemplateArgument > Converted)
Set new template arguments for this concept specialization.
Definition: ExprConcepts.cpp:64
clang::concepts::ExprRequirement::getExpr
Expr * getExpr() const
Definition: ExprConcepts.h:395
clang::concepts::ExprRequirement::ReturnTypeRequirement::isTypeConstraint
bool isTypeConstraint() const
Definition: ExprConcepts.h:315
clang::ConceptSpecializationExpr::NumTemplateArgs
unsigned NumTemplateArgs
The number of template arguments in the tail-allocated list of converted template arguments.
Definition: ExprConcepts.h:51
clang::concepts::Requirement::isSatisfied
bool isSatisfied() const
Definition: ExprConcepts.h:180
clang::concepts::TypeRequirement::getSatisfactionStatus
SatisfactionStatus getSatisfactionStatus() const
Definition: ExprConcepts.h:231
clang::concepts::ExprRequirement::getReturnTypeRequirementSubstitutedConstraintExpr
ConceptSpecializationExpr * getReturnTypeRequirementSubstitutedConstraintExpr() const
Definition: ExprConcepts.h:383
clang::concepts::Requirement::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Definition: ExprConcepts.h:198
clang::concepts::TypeRequirement::SS_Dependent
@ SS_Dependent
Definition: ExprConcepts.h:208
clang::ConceptSpecializationExpr::Satisfaction
ASTConstraintSatisfaction * Satisfaction
Information about the satisfaction of the named concept with the given arguments.
Definition: ExprConcepts.h:56
clang::RequiresExpr::Create
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, ArrayRef< ParmVarDecl * > LocalParameters, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
Definition: ExprConcepts.cpp:194
clang::Stmt::EmptyShell
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
Definition: Stmt.h:1105
clang::RequiresExpr::isSatisfied
bool isSatisfied() const
Whether or not the requires clause is satisfied.
Definition: ExprConcepts.h:526
clang::concepts::ExprRequirement::ReturnTypeRequirement::ReturnTypeRequirement
ReturnTypeRequirement(SubstitutionDiagnostic *SubstDiag)
A return type requirement was specified but it was a substitution failure.
Definition: ExprConcepts.h:284
clang::concepts::NestedRequirement::NestedRequirement
NestedRequirement(Expr *Constraint)
Definition: ExprConcepts.h:422
Decl.h
clang::concepts::ExprRequirement::ReturnTypeRequirement::ReturnTypeRequirement
ReturnTypeRequirement()
No return type requirement was specified.
Definition: ExprConcepts.h:280
clang::Diagnostic
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
Definition: Diagnostic.h:1561
clang::concepts::NestedRequirement::getConstraintSatisfaction
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
Definition: ExprConcepts.h:457
clang::concepts::Requirement::SubstitutionDiagnostic::SubstitutedEntity
StringRef SubstitutedEntity
Definition: ExprConcepts.h:164
clang::concepts::ExprRequirement::classof
static bool classof(const Requirement *R)
Definition: ExprConcepts.h:402
clang::concepts::ExprRequirement::ReturnTypeRequirement::isSubstitutionFailure
bool isSubstitutionFailure() const
Definition: ExprConcepts.h:310
clang::concepts::NestedRequirement::getConstraintExpr
Expr * getConstraintExpr() const
Definition: ExprConcepts.h:450
TemplateBase.h
clang::Stmt::child_iterator
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
Definition: Stmt.h:1251
DeclTemplate.h
clang::RequiresExprBodyDecl
Represents the body of a requires-expression.
Definition: DeclCXX.h:1959
clang::concepts::TypeRequirement::setSatisfactionStatus
void setSatisfactionStatus(SatisfactionStatus Status)
Definition: ExprConcepts.h:232
clang::concepts::ExprRequirement::SS_TypeRequirementSubstitutionFailure
@ SS_TypeRequirementSubstitutionFailure
Definition: ExprConcepts.h:266
clang::ConceptDecl
Declaration of a C++2a concept.
Definition: DeclTemplate.h:3253
clang::ConceptReference::ConceptName
DeclarationNameInfo ConceptName
The concept name used.
Definition: ASTConcept.h:109
clang::ConceptSpecializationExpr
Represents the specialization of a concept - evaluates to a prvalue of type bool.
Definition: ExprConcepts.h:40
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:208
NestedNameSpecifier.h
clang::concepts::Requirement::setSatisfied
void setSatisfied(bool IsSatisfied)
Definition: ExprConcepts.h:186
clang::RequiresExpr::getRBraceLoc
SourceLocation getRBraceLoc() const
Definition: ExprConcepts.h:536
clang::concepts::NestedRequirement
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
Definition: ExprConcepts.h:409
clang::ConceptReference::NamedConcept
ConceptDecl * NamedConcept
The concept named.
Definition: ASTConcept.h:118
clang::RequiresExpr::getBody
RequiresExprBodyDecl * getBody() const
Definition: ExprConcepts.h:518
clang::concepts::Requirement
A static requirement that can be used in a requires-expression to check properties of types and expre...
Definition: ExprConcepts.h:151
clang::ASTStmtReader
Definition: ASTReaderStmt.cpp:71
clang::ConceptSpecializationExpr::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprConcepts.h:130
clang::concepts::TypeRequirement::TypeRequirement
TypeRequirement(SubstitutionDiagnostic *Diagnostic)
Construct a type requirement when the nested name specifier is invalid due to a bad substitution.
Definition: ExprConcepts.h:227
Type.h
clang::Stmt::RequiresExprBits
RequiresExprBitfields RequiresExprBits
Definition: Stmt.h:1071
clang::Expr::isInstantiationDependent
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
Definition: Expr.h:214
Expr.h
clang::ConceptSpecializationExpr::Create
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)
Definition: ExprConcepts.cpp:72
clang::concepts::NestedRequirement::ASTStmtWriter
friend ASTStmtWriter
Definition: ExprConcepts.h:415
ASTContext.h
clang::RequiresExpr::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprConcepts.h:545
clang::concepts::ExprRequirement::SS_Dependent
@ SS_Dependent
Definition: ExprConcepts.h:263
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:69
clang::concepts::ExprRequirement::ReturnTypeRequirement::ASTStmtWriter
friend ASTStmtWriter
Definition: ExprConcepts.h:277
clang::ConceptSpecializationExpr::children
const_child_range children() const
Definition: ExprConcepts.h:142
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::concepts::TypeRequirement::classof
static bool classof(const Requirement *R)
Definition: ExprConcepts.h:253
clang::RequiresExpr::getLocalParameters
ArrayRef< ParmVarDecl * > getLocalParameters() const
Definition: ExprConcepts.h:514
clang::Stmt::child_range
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1254
clang::concepts::TypeRequirement::SatisfactionStatus
SatisfactionStatus
Definition: ExprConcepts.h:207
ASTConcept.h
This file provides AST data structures related to concepts.
clang::concepts::ExprRequirement::hasNoexceptRequirement
bool hasNoexceptRequirement() const
Definition: ExprConcepts.h:369
clang::ConceptSpecializationExpr::SubstitutionDiagnostic
std::pair< SourceLocation, std::string > SubstitutionDiagnostic
Definition: ExprConcepts.h:46
clang::concepts::TypeRequirement::isSubstitutionFailure
bool isSubstitutionFailure() const
Definition: ExprConcepts.h:236
clang::concepts::Requirement::RK_Compound
@ RK_Compound
Definition: ExprConcepts.h:155
clang::concepts::Requirement::RK_Simple
@ RK_Simple
Definition: ExprConcepts.h:155
clang::concepts::NestedRequirement::NestedRequirement
NestedRequirement(SubstitutionDiagnostic *SubstDiag)
Definition: ExprConcepts.h:417
clang::concepts::ExprRequirement::ASTStmtReader
friend ASTStmtReader
Definition: ExprConcepts.h:339
clang::ConceptReference::ArgsAsWritten
const ASTTemplateArgumentListInfo * ArgsAsWritten
The template argument list source info used to specialize the concept.
Definition: ASTConcept.h:122
clang::concepts::NestedRequirement::classof
static bool classof(const Requirement *R)
Definition: ExprConcepts.h:464
clang::concepts::TypeRequirement::SS_Satisfied
@ SS_Satisfied
Definition: ExprConcepts.h:210
clang::Stmt::const_child_range
llvm::iterator_range< const_child_iterator > const_child_range
Definition: Stmt.h:1255
clang::RequiresExpr::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprConcepts.h:542
clang::concepts::ExprRequirement::getSatisfactionStatus
SatisfactionStatus getSatisfactionStatus() const
Definition: ExprConcepts.h:372
clang::concepts::ExprRequirement::ExprRequirement
ExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc, ReturnTypeRequirement Req, SatisfactionStatus Status, ConceptSpecializationExpr *SubstitutedConstraintExpr=nullptr)
Construct a compound requirement.
Definition: SemaConcept.cpp:1069
clang::concepts::ExprRequirement::ReturnTypeRequirement::getSubstitutionDiagnostic
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
Definition: ExprConcepts.h:320
clang::concepts::Requirement::setDependent
void setDependent(bool IsDependent)
Definition: ExprConcepts.h:192
SourceLocation.h
clang::concepts::ExprRequirement::isCompound
bool isCompound() const
Definition: ExprConcepts.h:367
clang::Stmt::getStmtClass
StmtClass getStmtClass() const
Definition: Stmt.h:1165
clang::ConceptSpecializationExpr::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprConcepts.h:124
clang::concepts::ExprRequirement::SS_Satisfied
@ SS_Satisfied
Definition: ExprConcepts.h:268
false
#define false
Definition: stdbool.h:22
clang::ConceptSpecializationExpr::children
child_range children()
Definition: ExprConcepts.h:139
clang::concepts::TypeRequirement
A requires-expression requirement which queries the existence of a type name or type template special...
Definition: ExprConcepts.h:205
clang::ConceptReference
Common data class for constructs that reference concepts with template arguments.
Definition: ASTConcept.h:99
clang::ConceptSpecializationExpr::classof
static bool classof(const Stmt *T)
Definition: ExprConcepts.h:120
clang::concepts::ExprRequirement::ReturnTypeRequirement::ASTStmtReader
friend ASTStmtReader
Definition: ExprConcepts.h:276
clang::ASTConstraintSatisfaction::IsSatisfied
bool IsSatisfied
Definition: ASTConcept.h:80
llvm::ArrayRef
Definition: LLVM.h:34
Value
Value
Definition: UninitializedValues.cpp:102
clang::concepts::ExprRequirement::ReturnTypeRequirement::getTypeConstraintTemplateParameterList
TemplateParameterList * getTypeConstraintTemplateParameterList() const
Definition: ExprConcepts.h:327
clang::concepts::ExprRequirement::ASTStmtWriter
friend ASTStmtWriter
Definition: ExprConcepts.h:340
clang::concepts::ExprRequirement::SatisfactionStatus
SatisfactionStatus
Definition: ExprConcepts.h:262
clang::concepts::ExprRequirement::SS_NoexceptNotMet
@ SS_NoexceptNotMet
Definition: ExprConcepts.h:265
clang::concepts::TypeRequirement::getType
TypeSourceInfo * getType() const
Definition: ExprConcepts.h:247
clang::concepts::ExprRequirement::SS_ExprSubstitutionFailure
@ SS_ExprSubstitutionFailure
Definition: ExprConcepts.h:264
clang::concepts::NestedRequirement::ASTStmtReader
friend ASTStmtReader
Definition: ExprConcepts.h:414
clang::Expr::isValueDependent
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition: Expr.h:168
clang::Stmt::const_child_iterator
ConstStmtIterator const_child_iterator
Definition: Stmt.h:1252
DeclarationName.h
clang::concepts::ExprRequirement::ReturnTypeRequirement
Definition: ExprConcepts.h:270
clang::RequiresExpr::children
const_child_range children() const
Definition: ExprConcepts.h:553
clang::ConceptSpecializationExpr::getTemplateArguments
ArrayRef< TemplateArgument > getTemplateArguments() const
Definition: ExprConcepts.h:94
clang
Definition: CalledOnceCheck.h:17
clang::concepts::Requirement::SubstitutionDiagnostic::DiagMessage
StringRef DiagMessage
Definition: ExprConcepts.h:169
clang::ConceptSpecializationExpr::getSatisfaction
const ASTConstraintSatisfaction & getSatisfaction() const
Get elaborated satisfaction info about the template arguments' satisfaction of the named concept.
Definition: ExprConcepts.h:114
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:70
clang::concepts::Requirement::setContainsUnexpandedParameterPack
void setContainsUnexpandedParameterPack(bool Contains)
Definition: ExprConcepts.h:195
clang::RequiresExpr::classof
static bool classof(const Stmt *T)
Definition: ExprConcepts.h:538
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:110
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6530
clang::concepts::ExprRequirement::getNoexceptLoc
SourceLocation getNoexceptLoc() const
Definition: ExprConcepts.h:370
clang::ConceptSpecializationExpr::ConceptSpecializationExpr
ConceptSpecializationExpr(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten, ArrayRef< TemplateArgument > ConvertedArgs, const ConstraintSatisfaction *Satisfaction)
Definition: ExprConcepts.cpp:33
clang::ConstraintSatisfaction
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition: ASTConcept.h:28
clang::ConceptReference::getNestedNameSpecifierLoc
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
Definition: ASTConcept.h:136
clang::concepts::Requirement::Requirement
Requirement(RequirementKind Kind, bool IsDependent, bool ContainsUnexpandedParameterPack, bool IsSatisfied=true)
Definition: ExprConcepts.h:172
clang::concepts::Requirement::getKind
RequirementKind getKind() const
Definition: ExprConcepts.h:178
clang::ASTTemplateArgumentListInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:612
clang::concepts::Requirement::RK_Nested
@ RK_Nested
Definition: ExprConcepts.h:155
clang::TemplateParameterList::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Determine whether this template parameter list contains an unexpanded parameter pack.
Definition: DeclTemplate.cpp:94
true
#define true
Definition: stdbool.h:21
clang::ConceptReference::FoundDecl
NamedDecl * FoundDecl
The declaration found by name lookup when the expression was created.
Definition: ASTConcept.h:115
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::concepts::ExprRequirement
A requires-expression requirement which queries the validity and properties of an expression ('simple...
Definition: ExprConcepts.h:260
clang::concepts::NestedRequirement::isSubstitutionFailure
bool isSubstitutionFailure() const
Definition: ExprConcepts.h:439
clang::concepts::Requirement::RK_Type
@ RK_Type
Definition: ExprConcepts.h:155
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:767
clang::concepts::NestedRequirement::NestedRequirement
NestedRequirement(ASTContext &C, Expr *Constraint, const ConstraintSatisfaction &Satisfaction)
Definition: ExprConcepts.h:431
clang::concepts::ExprRequirement::isExprSubstitutionFailure
bool isExprSubstitutionFailure() const
Definition: ExprConcepts.h:374
clang::concepts::ExprRequirement::isSimple
bool isSimple() const
Definition: ExprConcepts.h:366
clang::ConceptSpecializationExpr::isSatisfied
bool isSatisfied() const
Whether or not the concept with the given arguments was satisfied when the expression was created.
Definition: ExprConcepts.h:105
clang::ASTTemplateArgumentListInfo::RAngleLoc
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
Definition: TemplateBase.h:629
clang::DeclarationNameInfo::getBeginLoc
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
Definition: DeclarationName.h:869
clang::TypeConstraint
Definition: ASTConcept.h:167
clang::concepts::Requirement::isDependent
bool isDependent() const
Definition: ExprConcepts.h:193
clang::concepts::TypeRequirement::ASTStmtWriter
friend ASTStmtWriter
Definition: ExprConcepts.h:217
clang::ConceptReference::TemplateKWLoc
SourceLocation TemplateKWLoc
The location of the template keyword, if specified when naming the concept.
Definition: ASTConcept.h:106
clang::concepts::ExprRequirement::getReturnTypeRequirement
const ReturnTypeRequirement & getReturnTypeRequirement() const
Definition: ExprConcepts.h:378
clang::concepts::ExprRequirement::SS_ConstraintsNotSatisfied
@ SS_ConstraintsNotSatisfied
Definition: ExprConcepts.h:267
clang::concepts::ExprRequirement::ReturnTypeRequirement::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Definition: ExprConcepts.h:299
clang::RequiresExpr::children
child_range children()
Definition: ExprConcepts.h:550
clang::concepts::ExprRequirement::ReturnTypeRequirement::isDependent
bool isDependent() const
Definition: ExprConcepts.h:295