//===--- ASTConcept.h - Concepts Related AST Data Structures ----*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// /// \file /// \brief This file provides AST data structures related to concepts. /// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_AST_ASTCONCEPT_H #define LLVM_CLANG_AST_ASTCONCEPT_H #include "clang/AST/DeclarationName.h" #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/TemplateBase.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/SmallVector.h" #include <utility> namespace clang { class ConceptDecl; class Expr; class NamedDecl; struct PrintingPolicy; /// The result of a constraint satisfaction check, containing the necessary /// information to diagnose an unsatisfied constraint. class ConstraintSatisfaction : public llvm::FoldingSetNode { … }; /// Pairs of unsatisfied atomic constraint expressions along with the /// substituted constraint expr, if the template arguments could be /// substituted into them, or a diagnostic if substitution resulted in /// an invalid expression. UnsatisfiedConstraintRecord; /// \brief The result of a constraint satisfaction check, containing the /// necessary information to diagnose an unsatisfied constraint. /// /// This is safe to store in an AST node, as opposed to ConstraintSatisfaction. struct ASTConstraintSatisfaction final : llvm::TrailingObjects<ASTConstraintSatisfaction, UnsatisfiedConstraintRecord> { … }; /// A reference to a concept and its template args, as it appears in the code. /// /// Examples: /// template <int X> requires is_even<X> int half = X/2; /// ~~~~~~~~~~ (in ConceptSpecializationExpr) /// /// std::input_iterator auto I = Container.begin(); /// ~~~~~~~~~~~~~~~~~~~ (in AutoTypeLoc) /// /// template <std::derives_from<Expr> T> void dump(); /// ~~~~~~~~~~~~~~~~~~~~~~~ (in TemplateTypeParmDecl) class ConceptReference { … }; /// Models the abbreviated syntax to constrain a template type parameter: /// template <convertible_to<string> T> void print(T object); /// ~~~~~~~~~~~~~~~~~~~~~~ /// Semantically, this adds an "immediately-declared constraint" with extra arg: /// requires convertible_to<T, string> /// /// In the C++ grammar, a type-constraint is also used for auto types: /// convertible_to<string> auto X = ...; /// We do *not* model these as TypeConstraints, but AutoType(Loc) directly. class TypeConstraint { … }; } // clang #endif // LLVM_CLANG_AST_ASTCONCEPT_H