Go to the documentation of this file.
9 #ifndef LLVM_CLANG_AST_INTERP_BOOLEAN_H
10 #define LLVM_CLANG_AST_INTERP_BOOLEAN_H
17 #include "llvm/ADT/APSInt.h"
18 #include "llvm/Support/MathExtras.h"
19 #include "llvm/Support/raw_ostream.h"
44 bool operator>(
unsigned RHS)
const {
return static_cast<unsigned>(
V) > RHS; }
50 explicit operator int64_t()
const {
return V; }
51 explicit operator uint64_t()
const {
return V; }
54 return APSInt(
APInt(1,
static_cast<uint64_t
>(
V),
false),
true);
63 constexpr
static unsigned bitWidth() {
return true; }
69 constexpr
static bool isSigned() {
return false; }
82 void print(llvm::raw_ostream &OS)
const { OS << (
V ?
"true" :
"false"); }
92 template <
unsigned SrcBits,
bool SrcSign>
93 static std::enable_if_t<SrcBits != 0, Boolean>
98 template <
bool SrcSign>
105 template <
typename T>
120 llvm_unreachable(
"Cannot decrement booleans");
Wrapper around numeric types.
constexpr static bool isMinusOne()
bool operator<(Boolean RHS) const
static Boolean min(unsigned NumBits)
bool operator==(Boolean RHS) const
bool operator>=(Boolean RHS) const
static Boolean max(unsigned NumBits)
Boolean operator~() const
bool operator>(Boolean RHS) const
void print(llvm::raw_ostream &OS) const
ComparisonCategoryResult Compare(const T &X, const T &Y)
Helper to compare two comparable types.
static Boolean from(Integral< 0, SrcSign > Value)
Wrapper around boolean types.
static bool inRange(int64_t Value, unsigned NumBits)
constexpr static bool isPositive()
bool operator!=(Boolean RHS) const
static std::enable_if_t< SrcBits !=0, Boolean > from(Integral< SrcBits, SrcSign > Value)
APSInt toAPSInt(unsigned NumBits) const
constexpr static bool isSigned()
bool operator>(unsigned RHS) const
Boolean()
Zero-initializes a boolean.
static bool add(Boolean A, Boolean B, unsigned OpBits, Boolean *R)
static std::enable_if_t< std::is_integral< T >::value, Boolean > from(T Value)
static bool sub(Boolean A, Boolean B, unsigned OpBits, Boolean *R)
static bool increment(Boolean A, Boolean *R)
Boolean truncate(unsigned TruncBits) const
APValue toAPValue() const
static bool decrement(Boolean A, Boolean *R)
static bool mul(Boolean A, Boolean B, unsigned OpBits, Boolean *R)
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
constexpr static unsigned bitWidth()
unsigned countLeadingZeros() const
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const Boolean &B)
ComparisonCategoryResult compare(const Boolean &RHS) const
constexpr static bool isNegative()
Boolean toUnsigned() const
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
static Boolean from(T Value, unsigned NumBits)
Boolean operator-() const
bool operator<=(Boolean RHS) const