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" 31 explicit Boolean(
bool V) : V(V) {}
44 bool operator>(
unsigned RHS)
const {
return static_cast<unsigned>(V) > RHS; }
49 explicit operator unsigned()
const {
return V; }
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"); }
88 static typename std::enable_if<std::is_integral<T>::value,
Boolean>
::type 93 template <
unsigned SrcBits,
bool SrcSign>
99 template <
bool SrcSign>
106 template <
typename T>
112 return Value == 0 || Value == 1;
121 llvm_unreachable(
"Cannot decrement booleans");
Boolean()
Zero-initializes a boolean.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static bool increment(Boolean A, Boolean *R)
ComparisonCategoryResult compare(const Boolean &RHS) const
static Boolean min(unsigned NumBits)
static std::enable_if< SrcBits !=0, Boolean >::type from(Integral< SrcBits, SrcSign > Value)
Wrapper around numeric types.
bool operator>(unsigned RHS) const
Wrapper around boolean types.
Boolean truncate(unsigned TruncBits) const
bool operator!=(Boolean RHS) const
static bool inRange(int64_t Value, unsigned NumBits)
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
static Boolean from(Integral< 0, SrcSign > Value)
APValue toAPValue() const
static bool add(Boolean A, Boolean B, unsigned OpBits, Boolean *R)
Boolean operator-() const
void print(llvm::raw_ostream &OS) const
static std::enable_if< std::is_integral< T >::value, Boolean >::type from(T Value)
static constexpr bool isSigned()
static Boolean from(T Value, unsigned NumBits)
APSInt toAPSInt(unsigned NumBits) const
bool operator>=(Boolean RHS) const
static constexpr bool isPositive()
static constexpr unsigned bitWidth()
static bool decrement(Boolean A, Boolean *R)
Boolean operator~() const
Boolean toUnsigned() const
static constexpr bool isMinusOne()
ComparisonCategoryResult Compare(const T &X, const T &Y)
Helper to compare two comparable types.
Dataflow Directional Tag Classes.
bool operator<(Boolean RHS) const
bool operator>(Boolean RHS) const
static bool sub(Boolean A, Boolean B, unsigned OpBits, Boolean *R)
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const Boolean &B)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
static constexpr bool isNegative()
bool operator==(Boolean RHS) const
bool operator<=(Boolean RHS) const
static Boolean max(unsigned NumBits)
static bool mul(Boolean A, Boolean B, unsigned OpBits, Boolean *R)
unsigned countLeadingZeros() const