//===- ComparisonCategories.h - Three Way Comparison Data -------*- 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 // //===----------------------------------------------------------------------===// // // This file defines the Comparison Category enum and data types, which // store the types and expressions needed to support operator<=> // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_AST_COMPARISONCATEGORIES_H #define LLVM_CLANG_AST_COMPARISONCATEGORIES_H #include "clang/Basic/LLVM.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/DenseMap.h" #include <array> #include <cassert> #include <optional> #include <vector> namespace llvm { class StringRef; class APSInt; } namespace clang { class ASTContext; class VarDecl; class CXXRecordDecl; class Sema; class QualType; class NamespaceDecl; /// An enumeration representing the different comparison categories /// types. /// /// C++20 [cmp.categories.pre] The types partial_ordering, weak_ordering, and /// strong_ordering are collectively termed the comparison category types. enum class ComparisonCategoryType : unsigned char { … }; /// Determine the common comparison type, as defined in C++2a /// [class.spaceship]p4. inline ComparisonCategoryType commonComparisonType(ComparisonCategoryType A, ComparisonCategoryType B) { … } /// Get the comparison category that should be used when comparing values of /// type \c T. std::optional<ComparisonCategoryType> getComparisonCategoryForBuiltinCmp(QualType T); /// An enumeration representing the possible results of a three-way /// comparison. These values map onto instances of comparison category types /// defined in the standard library. e.g. 'std::strong_ordering::less'. enum class ComparisonCategoryResult : unsigned char { … }; class ComparisonCategoryInfo { … }; class ComparisonCategories { … }; } // namespace clang #endif