clang  16.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  friend class ASTReader;
42  friend class ASTStmtReader;
43 
44 public:
45  using SubstitutionDiagnostic = std::pair<SourceLocation, std::string>;
46 
47 protected:
48  /// \brief The Implicit Concept Specialization Decl, which holds the template
49  /// arguments for this specialization.
51 
52  /// \brief Information about the satisfaction of the named concept with the
53  /// given arguments. If this expression is value dependent, this is to be
54  /// ignored.
56 
59  DeclarationNameInfo ConceptNameInfo,
64 
68  bool Dependent,
69  bool ContainsUnexpandedParameterPack);
71 
72 public:
80 
84  const ConstraintSatisfaction *Satisfaction, bool Dependent,
85  bool ContainsUnexpandedParameterPack);
86 
89  }
90 
92  assert(SpecDecl && "Template Argument Decl not initialized");
93  return SpecDecl;
94  }
95 
96  /// \brief Whether or not the concept with the given arguments was satisfied
97  /// when the expression was created.
98  /// The expression must not be dependent.
99  bool isSatisfied() const {
100  assert(!isValueDependent() &&
101  "isSatisfied called on a dependent ConceptSpecializationExpr");
102  return Satisfaction->IsSatisfied;
103  }
104 
105  /// \brief Get elaborated satisfaction info about the template arguments'
106  /// satisfaction of the named concept.
107  /// The expression must not be dependent.
109  assert(!isValueDependent() &&
110  "getSatisfaction called on dependent ConceptSpecializationExpr");
111  return *Satisfaction;
112  }
113 
114  static bool classof(const Stmt *T) {
115  return T->getStmtClass() == ConceptSpecializationExprClass;
116  }
117 
118  SourceLocation getBeginLoc() const LLVM_READONLY {
119  if (auto QualifierLoc = getNestedNameSpecifierLoc())
120  return QualifierLoc.getBeginLoc();
121  return ConceptName.getBeginLoc();
122  }
123 
124  SourceLocation getEndLoc() const LLVM_READONLY {
125  // If the ConceptSpecializationExpr is the ImmediatelyDeclaredConstraint
126  // of a TypeConstraint written syntactically as a constrained-parameter,
127  // there may not be a template argument list.
130  }
131 
132  // Iterators
135  }
138  }
139 };
140 
141 namespace concepts {
142 
143 /// \brief A static requirement that can be used in a requires-expression to
144 /// check properties of types and expression.
145 class Requirement {
146 public:
147  // Note - simple and compound requirements are both represented by the same
148  // class (ExprRequirement).
150 private:
151  const RequirementKind Kind;
152  // FIXME: use RequirementDependence to model dependence?
153  bool Dependent : 1;
154  bool ContainsUnexpandedParameterPack : 1;
155  bool Satisfied : 1;
156 public:
158  StringRef SubstitutedEntity;
159  // FIXME: Store diagnostics semantically and not as prerendered strings.
160  // Fixing this probably requires serialization of PartialDiagnostic
161  // objects.
163  StringRef DiagMessage;
164  };
165 
166  Requirement(RequirementKind Kind, bool IsDependent,
167  bool ContainsUnexpandedParameterPack, bool IsSatisfied = true) :
168  Kind(Kind), Dependent(IsDependent),
169  ContainsUnexpandedParameterPack(ContainsUnexpandedParameterPack),
170  Satisfied(IsSatisfied) {}
171 
172  RequirementKind getKind() const { return Kind; }
173 
174  bool isSatisfied() const {
175  assert(!Dependent &&
176  "isSatisfied can only be called on non-dependent requirements.");
177  return Satisfied;
178  }
179 
180  void setSatisfied(bool IsSatisfied) {
181  assert(!Dependent &&
182  "setSatisfied can only be called on non-dependent requirements.");
183  Satisfied = IsSatisfied;
184  }
185 
186  void setDependent(bool IsDependent) { Dependent = IsDependent; }
187  bool isDependent() const { return Dependent; }
188 
190  ContainsUnexpandedParameterPack = Contains;
191  }
193  return ContainsUnexpandedParameterPack;
194  }
195 };
196 
197 /// \brief A requires-expression requirement which queries the existence of a
198 /// type name or type template specialization ('type' requirements).
199 class TypeRequirement : public Requirement {
200 public:
205  };
206 private:
207  llvm::PointerUnion<SubstitutionDiagnostic *, TypeSourceInfo *> Value;
208  SatisfactionStatus Status;
209 public:
212 
213  /// \brief Construct a type requirement from a type. If the given type is not
214  /// dependent, this indicates that the type exists and the requirement will be
215  /// satisfied. Otherwise, the SubstitutionDiagnostic constructor is to be
216  /// used.
218 
219  /// \brief Construct a type requirement when the nested name specifier is
220  /// invalid due to a bad substitution. The requirement is unsatisfied.
223  Status(SS_SubstitutionFailure) {}
224 
225  SatisfactionStatus getSatisfactionStatus() const { return Status; }
227  this->Status = Status;
228  }
229 
230  bool isSubstitutionFailure() const {
231  return Status == SS_SubstitutionFailure;
232  }
233 
235  assert(Status == SS_SubstitutionFailure &&
236  "Attempted to get substitution diagnostic when there has been no "
237  "substitution failure.");
238  return Value.get<SubstitutionDiagnostic *>();
239  }
240 
242  assert(!isSubstitutionFailure() &&
243  "Attempted to get type when there has been a substitution failure.");
244  return Value.get<TypeSourceInfo *>();
245  }
246 
247  static bool classof(const Requirement *R) {
248  return R->getKind() == RK_Type;
249  }
250 };
251 
252 /// \brief A requires-expression requirement which queries the validity and
253 /// properties of an expression ('simple' and 'compound' requirements).
254 class ExprRequirement : public Requirement {
255 public:
263  };
265  llvm::PointerIntPair<
266  llvm::PointerUnion<TemplateParameterList *, SubstitutionDiagnostic *>,
267  1, bool>
268  TypeConstraintInfo;
269  public:
272 
273  /// \brief No return type requirement was specified.
274  ReturnTypeRequirement() : TypeConstraintInfo(nullptr, false) {}
275 
276  /// \brief A return type requirement was specified but it was a
277  /// substitution failure.
278  ReturnTypeRequirement(SubstitutionDiagnostic *SubstDiag) :
279  TypeConstraintInfo(SubstDiag, false) {}
280 
281  /// \brief A 'type constraint' style return type requirement.
282  /// \param TPL an invented template parameter list containing a single
283  /// type parameter with a type-constraint.
284  // TODO: Can we maybe not save the whole template parameter list and just
285  // the type constraint? Saving the whole TPL makes it easier to handle in
286  // serialization but is less elegant.
288 
289  bool isDependent() const {
290  return TypeConstraintInfo.getInt();
291  }
292 
294  if (!isTypeConstraint())
295  return false;
298  }
299 
300  bool isEmpty() const {
301  return TypeConstraintInfo.getPointer().isNull();
302  }
303 
304  bool isSubstitutionFailure() const {
305  return !isEmpty() &&
306  TypeConstraintInfo.getPointer().is<SubstitutionDiagnostic *>();
307  }
308 
309  bool isTypeConstraint() const {
310  return !isEmpty() &&
311  TypeConstraintInfo.getPointer().is<TemplateParameterList *>();
312  }
313 
314  SubstitutionDiagnostic *getSubstitutionDiagnostic() const {
315  assert(isSubstitutionFailure());
316  return TypeConstraintInfo.getPointer().get<SubstitutionDiagnostic *>();
317  }
318 
319  const TypeConstraint *getTypeConstraint() const;
320 
322  assert(isTypeConstraint());
323  return TypeConstraintInfo.getPointer().get<TemplateParameterList *>();
324  }
325  };
326 private:
327  llvm::PointerUnion<Expr *, SubstitutionDiagnostic *> Value;
328  SourceLocation NoexceptLoc; // May be empty if noexcept wasn't specified.
329  ReturnTypeRequirement TypeReq;
330  ConceptSpecializationExpr *SubstitutedConstraintExpr;
331  SatisfactionStatus Status;
332 public:
335 
336  /// \brief Construct a compound requirement.
337  /// \param E the expression which is checked by this requirement.
338  /// \param IsSimple whether this was a simple requirement in source.
339  /// \param NoexceptLoc the location of the noexcept keyword, if it was
340  /// specified, otherwise an empty location.
341  /// \param Req the requirement for the type of the checked expression.
342  /// \param Status the satisfaction status of this requirement.
344  Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
346  ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr);
347 
348  /// \brief Construct a compound requirement whose expression was a
349  /// substitution failure. The requirement is not satisfied.
350  /// \param E the diagnostic emitted while instantiating the original
351  /// expression.
352  /// \param IsSimple whether this was a simple requirement in source.
353  /// \param NoexceptLoc the location of the noexcept keyword, if it was
354  /// specified, otherwise an empty location.
355  /// \param Req the requirement for the type of the checked expression (omit
356  /// if no requirement was specified).
357  ExprRequirement(SubstitutionDiagnostic *E, bool IsSimple,
358  SourceLocation NoexceptLoc, ReturnTypeRequirement Req = {});
359 
360  bool isSimple() const { return getKind() == RK_Simple; }
361  bool isCompound() const { return getKind() == RK_Compound; }
362 
363  bool hasNoexceptRequirement() const { return NoexceptLoc.isValid(); }
364  SourceLocation getNoexceptLoc() const { return NoexceptLoc; }
365 
366  SatisfactionStatus getSatisfactionStatus() const { return Status; }
367 
369  return Status == SS_ExprSubstitutionFailure;
370  }
371 
373  return TypeReq;
374  }
375 
378  assert(Status >= SS_TypeRequirementSubstitutionFailure);
379  return SubstitutedConstraintExpr;
380  }
381 
382  SubstitutionDiagnostic *getExprSubstitutionDiagnostic() const {
383  assert(isExprSubstitutionFailure() &&
384  "Attempted to get expression substitution diagnostic when there has "
385  "been no expression substitution failure");
386  return Value.get<SubstitutionDiagnostic *>();
387  }
388 
389  Expr *getExpr() const {
390  assert(!isExprSubstitutionFailure() &&
391  "ExprRequirement has no expression because there has been a "
392  "substitution failure.");
393  return Value.get<Expr *>();
394  }
395 
396  static bool classof(const Requirement *R) {
397  return R->getKind() == RK_Compound || R->getKind() == RK_Simple;
398  }
399 };
400 
401 /// \brief A requires-expression requirement which is satisfied when a general
402 /// constraint expression is satisfied ('nested' requirements).
404  llvm::PointerUnion<Expr *, SubstitutionDiagnostic *> Value;
405  const ASTConstraintSatisfaction *Satisfaction = nullptr;
406 
407 public:
410 
411  NestedRequirement(SubstitutionDiagnostic *SubstDiag) :
412  Requirement(RK_Nested, /*IsDependent=*/false,
413  /*ContainsUnexpandedParameterPack*/false,
414  /*IsSatisfied=*/false), Value(SubstDiag) {}
415 
416  NestedRequirement(Expr *Constraint) :
417  Requirement(RK_Nested, /*IsDependent=*/true,
418  Constraint->containsUnexpandedParameterPack()),
419  Value(Constraint) {
420  assert(Constraint->isInstantiationDependent() &&
421  "Nested requirement with non-dependent constraint must be "
422  "constructed with a ConstraintSatisfaction object");
423  }
424 
426  const ConstraintSatisfaction &Satisfaction) :
427  Requirement(RK_Nested, Constraint->isInstantiationDependent(),
428  Constraint->containsUnexpandedParameterPack(),
429  Satisfaction.IsSatisfied),
430  Value(Constraint),
431  Satisfaction(ASTConstraintSatisfaction::Create(C, Satisfaction)) {}
432 
433  bool isSubstitutionFailure() const {
434  return Value.is<SubstitutionDiagnostic *>();
435  }
436 
437  SubstitutionDiagnostic *getSubstitutionDiagnostic() const {
438  assert(isSubstitutionFailure() &&
439  "getSubstitutionDiagnostic() may not be called when there was no "
440  "substitution failure.");
441  return Value.get<SubstitutionDiagnostic *>();
442  }
443 
445  assert(!isSubstitutionFailure() && "getConstraintExpr() may not be called "
446  "on nested requirements with "
447  "substitution failures.");
448  return Value.get<Expr *>();
449  }
450 
452  assert(!isSubstitutionFailure() && "getConstraintSatisfaction() may not be "
453  "called on nested requirements with "
454  "substitution failures.");
455  return *Satisfaction;
456  }
457 
458  static bool classof(const Requirement *R) {
459  return R->getKind() == RK_Nested;
460  }
461 };
462 
463 } // namespace concepts
464 
465 /// C++2a [expr.prim.req]:
466 /// A requires-expression provides a concise way to express requirements on
467 /// template arguments. A requirement is one that can be checked by name
468 /// lookup (6.4) or by checking properties of types and expressions.
469 /// [...]
470 /// A requires-expression is a prvalue of type bool [...]
471 class RequiresExpr final : public Expr,
472  llvm::TrailingObjects<RequiresExpr, ParmVarDecl *,
473  concepts::Requirement *> {
474  friend TrailingObjects;
475  friend class ASTStmtReader;
476 
477  unsigned NumLocalParameters;
478  unsigned NumRequirements;
479  RequiresExprBodyDecl *Body;
480  SourceLocation RBraceLoc;
481 
482  unsigned numTrailingObjects(OverloadToken<ParmVarDecl *>) const {
483  return NumLocalParameters;
484  }
485 
486  unsigned numTrailingObjects(OverloadToken<concepts::Requirement *>) const {
487  return NumRequirements;
488  }
489 
490  RequiresExpr(ASTContext &C, SourceLocation RequiresKWLoc,
491  RequiresExprBodyDecl *Body,
492  ArrayRef<ParmVarDecl *> LocalParameters,
493  ArrayRef<concepts::Requirement *> Requirements,
494  SourceLocation RBraceLoc);
495  RequiresExpr(ASTContext &C, EmptyShell Empty, unsigned NumLocalParameters,
496  unsigned NumRequirements);
497 
498 public:
499  static RequiresExpr *
500  Create(ASTContext &C, SourceLocation RequiresKWLoc,
501  RequiresExprBodyDecl *Body, ArrayRef<ParmVarDecl *> LocalParameters,
502  ArrayRef<concepts::Requirement *> Requirements,
503  SourceLocation RBraceLoc);
504  static RequiresExpr *
505  Create(ASTContext &C, EmptyShell Empty, unsigned NumLocalParameters,
506  unsigned NumRequirements);
507 
509  return {getTrailingObjects<ParmVarDecl *>(), NumLocalParameters};
510  }
511 
512  RequiresExprBodyDecl *getBody() const { return Body; }
513 
515  return {getTrailingObjects<concepts::Requirement *>(), NumRequirements};
516  }
517 
518  /// \brief Whether or not the requires clause is satisfied.
519  /// The expression must not be dependent.
520  bool isSatisfied() const {
521  assert(!isValueDependent()
522  && "isSatisfied called on a dependent RequiresExpr");
523  return RequiresExprBits.IsSatisfied;
524  }
525 
527  return RequiresExprBits.RequiresKWLoc;
528  }
529 
530  SourceLocation getRBraceLoc() const { return RBraceLoc; }
531 
532  static bool classof(const Stmt *T) {
533  return T->getStmtClass() == RequiresExprClass;
534  }
535 
536  SourceLocation getBeginLoc() const LLVM_READONLY {
537  return RequiresExprBits.RequiresKWLoc;
538  }
539  SourceLocation getEndLoc() const LLVM_READONLY {
540  return RBraceLoc;
541  }
542 
543  // Iterators
546  }
549  }
550 };
551 
552 } // namespace clang
553 
554 #endif // LLVM_CLANG_AST_EXPRCONCEPTS_H
clang::concepts::TypeRequirement::TypeRequirement
TypeRequirement(TypeSourceInfo *T)
Construct a type requirement from a type.
Definition: SemaConcept.cpp:1522
clang::concepts::Requirement::RequirementKind
RequirementKind
Definition: ExprConcepts.h:149
clang::concepts::ExprRequirement::getExprSubstitutionDiagnostic
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
Definition: ExprConcepts.h:382
clang::ASTConstraintSatisfaction
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition: ASTConcept.h:77
clang::concepts::Requirement::SubstitutionDiagnostic::DiagLoc
SourceLocation DiagLoc
Definition: ExprConcepts.h:162
clang::concepts::ExprRequirement::ReturnTypeRequirement::getTypeConstraint
const TypeConstraint * getTypeConstraint() const
Definition: ExprConcepts.cpp:107
clang::RequiresExpr::getRequiresKWLoc
SourceLocation getRequiresKWLoc() const
Definition: ExprConcepts.h:526
clang::concepts::TypeRequirement::getSubstitutionDiagnostic
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
Definition: ExprConcepts.h:234
clang::concepts::TypeRequirement::ASTStmtReader
friend ASTStmtReader
Definition: ExprConcepts.h:210
clang::RequiresExpr::getRequirements
ArrayRef< concepts::Requirement * > getRequirements() const
Definition: ExprConcepts.h:514
clang::concepts::TypeRequirement::SS_SubstitutionFailure
@ SS_SubstitutionFailure
Definition: ExprConcepts.h:203
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:300
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:56
clang::DeclarationNameInfo::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclarationName.h:876
clang::concepts::Requirement::SubstitutionDiagnostic
Definition: ExprConcepts.h:157
clang::RequiresExpr
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:471
clang::concepts::NestedRequirement::getSubstitutionDiagnostic
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
Definition: ExprConcepts.h:437
clang::ImplicitConceptSpecializationDecl::getTemplateArguments
ArrayRef< TemplateArgument > getTemplateArguments() const
Definition: DeclTemplate.h:3327
clang::concepts::ExprRequirement::getExpr
Expr * getExpr() const
Definition: ExprConcepts.h:389
clang::concepts::ExprRequirement::ReturnTypeRequirement::isTypeConstraint
bool isTypeConstraint() const
Definition: ExprConcepts.h:309
clang::concepts::Requirement::isSatisfied
bool isSatisfied() const
Definition: ExprConcepts.h:174
clang::concepts::TypeRequirement::getSatisfactionStatus
SatisfactionStatus getSatisfactionStatus() const
Definition: ExprConcepts.h:225
clang::concepts::ExprRequirement::getReturnTypeRequirementSubstitutedConstraintExpr
ConceptSpecializationExpr * getReturnTypeRequirementSubstitutedConstraintExpr() const
Definition: ExprConcepts.h:377
clang::concepts::Requirement::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Definition: ExprConcepts.h:192
clang::concepts::TypeRequirement::SS_Dependent
@ SS_Dependent
Definition: ExprConcepts.h:202
clang::ConceptSpecializationExpr::Satisfaction
ASTConstraintSatisfaction * Satisfaction
Information about the satisfaction of the named concept with the given arguments.
Definition: ExprConcepts.h:55
clang::RequiresExpr::Create
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, ArrayRef< ParmVarDecl * > LocalParameters, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
Definition: ExprConcepts.cpp:165
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:1109
clang::RequiresExpr::isSatisfied
bool isSatisfied() const
Whether or not the requires clause is satisfied.
Definition: ExprConcepts.h:520
clang::concepts::ExprRequirement::ReturnTypeRequirement::ReturnTypeRequirement
ReturnTypeRequirement(SubstitutionDiagnostic *SubstDiag)
A return type requirement was specified but it was a substitution failure.
Definition: ExprConcepts.h:278
clang::concepts::NestedRequirement::NestedRequirement
NestedRequirement(Expr *Constraint)
Definition: ExprConcepts.h:416
Decl.h
clang::concepts::ExprRequirement::ReturnTypeRequirement::ReturnTypeRequirement
ReturnTypeRequirement()
No return type requirement was specified.
Definition: ExprConcepts.h:274
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:451
clang::concepts::Requirement::SubstitutionDiagnostic::SubstitutedEntity
StringRef SubstitutedEntity
Definition: ExprConcepts.h:158
clang::concepts::ExprRequirement::classof
static bool classof(const Requirement *R)
Definition: ExprConcepts.h:396
clang::concepts::ExprRequirement::ReturnTypeRequirement::isSubstitutionFailure
bool isSubstitutionFailure() const
Definition: ExprConcepts.h:304
clang::concepts::NestedRequirement::getConstraintExpr
Expr * getConstraintExpr() const
Definition: ExprConcepts.h:444
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:1255
DeclTemplate.h
clang::RequiresExprBodyDecl
Represents the body of a requires-expression.
Definition: DeclCXX.h:1961
clang::concepts::TypeRequirement::setSatisfactionStatus
void setSatisfactionStatus(SatisfactionStatus Status)
Definition: ExprConcepts.h:226
clang::concepts::ExprRequirement::SS_TypeRequirementSubstitutionFailure
@ SS_TypeRequirementSubstitutionFailure
Definition: ExprConcepts.h:260
clang::ConceptDecl
Declaration of a C++20 concept.
Definition: DeclTemplate.h:3262
clang::ConceptReference::ConceptName
DeclarationNameInfo ConceptName
The concept name used.
Definition: ASTConcept.h:111
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:209
NestedNameSpecifier.h
clang::concepts::Requirement::setSatisfied
void setSatisfied(bool IsSatisfied)
Definition: ExprConcepts.h:180
clang::RequiresExpr::getRBraceLoc
SourceLocation getRBraceLoc() const
Definition: ExprConcepts.h:530
clang::concepts::NestedRequirement
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
Definition: ExprConcepts.h:403
clang::ConceptReference::NamedConcept
ConceptDecl * NamedConcept
The concept named.
Definition: ASTConcept.h:120
clang::RequiresExpr::getBody
RequiresExprBodyDecl * getBody() const
Definition: ExprConcepts.h:512
clang::concepts::Requirement
A static requirement that can be used in a requires-expression to check properties of types and expre...
Definition: ExprConcepts.h:145
clang::ASTStmtReader
Definition: ASTReaderStmt.cpp:71
clang::ConceptSpecializationExpr::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprConcepts.h:124
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:221
Type.h
clang::Stmt::RequiresExprBits
RequiresExprBitfields RequiresExprBits
Definition: Stmt.h:1075
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::concepts::NestedRequirement::ASTStmtWriter
friend ASTStmtWriter
Definition: ExprConcepts.h:409
ASTContext.h
clang::RequiresExpr::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprConcepts.h:539
clang::concepts::ExprRequirement::SS_Dependent
@ SS_Dependent
Definition: ExprConcepts.h:257
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:70
clang::concepts::ExprRequirement::ReturnTypeRequirement::ASTStmtWriter
friend ASTStmtWriter
Definition: ExprConcepts.h:271
clang::ConceptSpecializationExpr::children
const_child_range children() const
Definition: ExprConcepts.h:136
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:247
clang::RequiresExpr::getLocalParameters
ArrayRef< ParmVarDecl * > getLocalParameters() const
Definition: ExprConcepts.h:508
clang::Stmt::child_range
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1258
clang::concepts::TypeRequirement::SatisfactionStatus
SatisfactionStatus
Definition: ExprConcepts.h:201
ASTConcept.h
This file provides AST data structures related to concepts.
clang::concepts::ExprRequirement::hasNoexceptRequirement
bool hasNoexceptRequirement() const
Definition: ExprConcepts.h:363
clang::ConceptSpecializationExpr::SubstitutionDiagnostic
std::pair< SourceLocation, std::string > SubstitutionDiagnostic
Definition: ExprConcepts.h:45
clang::concepts::TypeRequirement::isSubstitutionFailure
bool isSubstitutionFailure() const
Definition: ExprConcepts.h:230
clang::concepts::Requirement::RK_Compound
@ RK_Compound
Definition: ExprConcepts.h:149
clang::concepts::Requirement::RK_Simple
@ RK_Simple
Definition: ExprConcepts.h:149
clang::concepts::NestedRequirement::NestedRequirement
NestedRequirement(SubstitutionDiagnostic *SubstDiag)
Definition: ExprConcepts.h:411
clang::concepts::ExprRequirement::ASTStmtReader
friend ASTStmtReader
Definition: ExprConcepts.h:333
clang::ConceptReference::ArgsAsWritten
const ASTTemplateArgumentListInfo * ArgsAsWritten
The template argument list source info used to specialize the concept.
Definition: ASTConcept.h:124
clang::concepts::NestedRequirement::classof
static bool classof(const Requirement *R)
Definition: ExprConcepts.h:458
clang::concepts::TypeRequirement::SS_Satisfied
@ SS_Satisfied
Definition: ExprConcepts.h:204
clang::Stmt::const_child_range
llvm::iterator_range< const_child_iterator > const_child_range
Definition: Stmt.h:1259
clang::RequiresExpr::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprConcepts.h:536
clang::concepts::ExprRequirement::getSatisfactionStatus
SatisfactionStatus getSatisfactionStatus() const
Definition: ExprConcepts.h:366
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:1475
clang::concepts::ExprRequirement::ReturnTypeRequirement::getSubstitutionDiagnostic
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
Definition: ExprConcepts.h:314
clang::concepts::Requirement::setDependent
void setDependent(bool IsDependent)
Definition: ExprConcepts.h:186
SourceLocation.h
clang::concepts::ExprRequirement::isCompound
bool isCompound() const
Definition: ExprConcepts.h:361
clang::Stmt::getStmtClass
StmtClass getStmtClass() const
Definition: Stmt.h:1169
clang::ConceptSpecializationExpr::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprConcepts.h:118
clang::ConceptSpecializationExpr::Create
static ConceptSpecializationExpr * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
Definition: ExprConcepts.cpp:61
clang::concepts::ExprRequirement::SS_Satisfied
@ SS_Satisfied
Definition: ExprConcepts.h:262
false
#define false
Definition: stdbool.h:22
clang::ConceptSpecializationExpr::children
child_range children()
Definition: ExprConcepts.h:133
clang::concepts::TypeRequirement
A requires-expression requirement which queries the existence of a type name or type template special...
Definition: ExprConcepts.h:199
clang::ConceptReference
Common data class for constructs that reference concepts with template arguments.
Definition: ASTConcept.h:101
clang::ConceptSpecializationExpr::classof
static bool classof(const Stmt *T)
Definition: ExprConcepts.h:114
clang::concepts::ExprRequirement::ReturnTypeRequirement::ASTStmtReader
friend ASTStmtReader
Definition: ExprConcepts.h:270
clang::ImplicitConceptSpecializationDecl
Definition: DeclTemplate.h:3309
clang::ConceptSpecializationExpr::ConceptSpecializationExpr
ConceptSpecializationExpr(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
Definition: ExprConcepts.cpp:33
clang::ASTConstraintSatisfaction::IsSatisfied
bool IsSatisfied
Definition: ASTConcept.h:81
llvm::ArrayRef< TemplateArgument >
Value
Value
Definition: UninitializedValues.cpp:103
clang::concepts::ExprRequirement::ReturnTypeRequirement::getTypeConstraintTemplateParameterList
TemplateParameterList * getTypeConstraintTemplateParameterList() const
Definition: ExprConcepts.h:321
clang::concepts::ExprRequirement::ASTStmtWriter
friend ASTStmtWriter
Definition: ExprConcepts.h:334
clang::concepts::ExprRequirement::SatisfactionStatus
SatisfactionStatus
Definition: ExprConcepts.h:256
clang::concepts::ExprRequirement::SS_NoexceptNotMet
@ SS_NoexceptNotMet
Definition: ExprConcepts.h:259
clang::concepts::TypeRequirement::getType
TypeSourceInfo * getType() const
Definition: ExprConcepts.h:241
clang::concepts::ExprRequirement::SS_ExprSubstitutionFailure
@ SS_ExprSubstitutionFailure
Definition: ExprConcepts.h:258
clang::concepts::NestedRequirement::ASTStmtReader
friend ASTStmtReader
Definition: ExprConcepts.h:408
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:1256
clang::ASTReader
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:341
DeclarationName.h
clang::concepts::ExprRequirement::ReturnTypeRequirement
Definition: ExprConcepts.h:264
clang::RequiresExpr::children
const_child_range children() const
Definition: ExprConcepts.h:547
clang::ConceptSpecializationExpr::getTemplateArguments
ArrayRef< TemplateArgument > getTemplateArguments() const
Definition: ExprConcepts.h:87
clang
Definition: CalledOnceCheck.h:17
clang::concepts::Requirement::SubstitutionDiagnostic::DiagMessage
StringRef DiagMessage
Definition: ExprConcepts.h:163
clang::ConceptSpecializationExpr::getSatisfaction
const ASTConstraintSatisfaction & getSatisfaction() const
Get elaborated satisfaction info about the template arguments' satisfaction of the named concept.
Definition: ExprConcepts.h:108
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:71
clang::concepts::Requirement::setContainsUnexpandedParameterPack
void setContainsUnexpandedParameterPack(bool Contains)
Definition: ExprConcepts.h:189
clang::RequiresExpr::classof
static bool classof(const Stmt *T)
Definition: ExprConcepts.h:532
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:6593
clang::concepts::ExprRequirement::getNoexceptLoc
SourceLocation getNoexceptLoc() const
Definition: ExprConcepts.h:364
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:138
clang::concepts::Requirement::Requirement
Requirement(RequirementKind Kind, bool IsDependent, bool ContainsUnexpandedParameterPack, bool IsSatisfied=true)
Definition: ExprConcepts.h:166
clang::concepts::Requirement::getKind
RequirementKind getKind() const
Definition: ExprConcepts.h:172
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:149
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:117
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:254
clang::concepts::NestedRequirement::isSubstitutionFailure
bool isSubstitutionFailure() const
Definition: ExprConcepts.h:433
clang::concepts::Requirement::RK_Type
@ RK_Type
Definition: ExprConcepts.h:149
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:425
clang::concepts::ExprRequirement::isExprSubstitutionFailure
bool isExprSubstitutionFailure() const
Definition: ExprConcepts.h:368
clang::ConceptSpecializationExpr::SpecDecl
ImplicitConceptSpecializationDecl * SpecDecl
The Implicit Concept Specialization Decl, which holds the template arguments for this specialization.
Definition: ExprConcepts.h:50
clang::concepts::ExprRequirement::isSimple
bool isSimple() const
Definition: ExprConcepts.h:360
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:99
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:169
clang::concepts::Requirement::isDependent
bool isDependent() const
Definition: ExprConcepts.h:187
clang::concepts::TypeRequirement::ASTStmtWriter
friend ASTStmtWriter
Definition: ExprConcepts.h:211
clang::ConceptReference::TemplateKWLoc
SourceLocation TemplateKWLoc
The location of the template keyword, if specified when naming the concept.
Definition: ASTConcept.h:108
clang::concepts::ExprRequirement::getReturnTypeRequirement
const ReturnTypeRequirement & getReturnTypeRequirement() const
Definition: ExprConcepts.h:372
clang::concepts::ExprRequirement::SS_ConstraintsNotSatisfied
@ SS_ConstraintsNotSatisfied
Definition: ExprConcepts.h:261
clang::concepts::ExprRequirement::ReturnTypeRequirement::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Definition: ExprConcepts.h:293
clang::RequiresExpr::children
child_range children()
Definition: ExprConcepts.h:544
clang::concepts::ExprRequirement::ReturnTypeRequirement::isDependent
bool isDependent() const
Definition: ExprConcepts.h:289
clang::ConceptSpecializationExpr::getSpecializationDecl
const ImplicitConceptSpecializationDecl * getSpecializationDecl() const
Definition: ExprConcepts.h:91