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