9#ifndef LLVM_CLANG_AST_INTERP_BOOLEAN_H
10#define LLVM_CLANG_AST_INTERP_BOOLEAN_H
15#include "llvm/ADT/APSInt.h"
16#include "llvm/Support/MathExtras.h"
17#include "llvm/Support/raw_ostream.h"
37 bool operator>(
unsigned RHS)
const {
return static_cast<unsigned>(
V) > RHS; }
44 template <
typename Ty,
typename = std::enable_if_t<std::is_
integral_v<Ty>>>
45 explicit operator Ty()
const {
50 return APSInt(
APInt(1,
static_cast<uint64_t
>(
V),
false),
true);
59 constexpr static unsigned bitWidth() {
return 1; }
65 constexpr static bool isSigned() {
return false; }
80 bool Val =
static_cast<bool>(*Buff);
86 void print(llvm::raw_ostream &OS)
const { OS << (
V ?
"true" :
"false"); }
89 llvm::raw_string_ostream OS(NameStr);
98 if constexpr (std::is_integral<T>::value)
100 return Boolean(
static_cast<decltype(Boolean::V)
>(
Value) != 0);
103 template <
unsigned SrcBits,
bool SrcSign>
104 static std::enable_if_t<SrcBits != 0, Boolean>
125 llvm_unreachable(
"Cannot decrement booleans");
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Wrapper around boolean types.
Boolean operator-() const
static Boolean from(T Value, unsigned NumBits)
ComparisonCategoryResult compare(const Boolean &RHS) const
static Boolean max(unsigned NumBits)
static Boolean min(unsigned NumBits)
Boolean operator-(const Boolean &Other) const
static bool inv(Boolean A, Boolean *R)
static bool decrement(Boolean A, Boolean *R)
bool operator>(unsigned RHS) const
APSInt toAPSInt(unsigned NumBits) const
Boolean toUnsigned() const
static constexpr unsigned bitWidth()
static constexpr bool isSigned()
std::string toDiagnosticString(const ASTContext &Ctx) const
bool operator<(Boolean RHS) const
APValue toAPValue(const ASTContext &) const
Boolean truncate(unsigned TruncBits) const
bool operator>(Boolean RHS) const
static std::enable_if_t< SrcBits !=0, Boolean > from(Integral< SrcBits, SrcSign > Value)
Boolean operator!() const
static constexpr bool isNegative()
static bool mul(Boolean A, Boolean B, unsigned OpBits, Boolean *R)
unsigned countLeadingZeros() const
void print(llvm::raw_ostream &OS) const
static constexpr bool isPositive()
Boolean()
Zero-initializes a boolean.
static bool neg(Boolean A, Boolean *R)
static Boolean from(T Value)
static bool inRange(int64_t Value, unsigned NumBits)
static bool increment(Boolean A, Boolean *R)
static bool sub(Boolean A, Boolean B, unsigned OpBits, Boolean *R)
static constexpr bool isMinusOne()
static bool add(Boolean A, Boolean B, unsigned OpBits, Boolean *R)
static Boolean bitcastFromMemory(const std::byte *Buff, unsigned BitWidth)
void bitcastToMemory(std::byte *Buff)
Boolean operator~() const
Wrapper around numeric types.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const Boolean &B)
ComparisonCategoryResult Compare(const T &X, const T &Y)
Helper to compare two comparable types.
The JSON file list parser is used to communicate input to InstallAPI.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
const FunctionProtoType * T
@ Other
Other implicit parameter.