13#ifndef LLVM_CLANG_AST_CHARUNITS_H
14#define LLVM_CLANG_AST_CHARUNITS_H
16#include "llvm/ADT/DenseMapInfo.h"
17#include "llvm/Support/Alignment.h"
18#include "llvm/Support/DataTypes.h"
19#include "llvm/Support/MathExtras.h"
75 Quantity +=
Other.Quantity;
86 Quantity -=
Other.Quantity;
99 return Quantity ==
Other.Quantity;
102 return Quantity !=
Other.Quantity;
107 return Quantity <
Other.Quantity;
110 return Quantity <=
Other.Quantity;
113 return Quantity >
Other.Quantity;
116 return Quantity >=
Other.Quantity;
122 bool isZero()
const {
return Quantity == 0; }
125 bool isOne()
const {
return Quantity == 1; }
136 return (Quantity & -Quantity) == Quantity;
144 return (*
this % N) == 0;
163 return Quantity /
Other.Quantity;
169 return Quantity %
Other.Quantity;
189 llvm::Align
getAsAlign()
const {
return llvm::Align(Quantity); }
195 return llvm::MaybeAlign(Quantity);
202 return CharUnits(llvm::alignTo(Quantity, Align.Quantity));
208 assert(Quantity != 0 &&
"offsetting from unknown alignment?");
209 return CharUnits(llvm::MinAlign(Quantity, offset.Quantity));
232template<>
struct DenseMapInfo<
clang::CharUnits> {
235 DenseMapInfo<clang::CharUnits::QuantityType>::getEmptyKey();
242 DenseMapInfo<clang::CharUnits::QuantityType>::getTombstoneKey();
249 return DenseMapInfo<clang::CharUnits::QuantityType>::getHashValue(Quantity);
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
CharUnits - This is an opaque type for sizes expressed in character units.
CharUnits operator-() const
bool isPowerOfTwo() const
isPowerOfTwo - Test whether the quantity is a power of two.
CharUnits alignmentAtOffset(CharUnits offset) const
Given that this is a non-zero alignment value, what is the alignment at the given offset?
bool isNegative() const
isNegative - Test whether the quantity is less than zero.
CharUnits & operator*=(QuantityType N)
bool isPositive() const
isPositive - Test whether the quantity is greater than zero.
bool isZero() const
isZero - Test whether the quantity equals zero.
CharUnits & operator-=(const CharUnits &Other)
bool operator<(const CharUnits &Other) const
CharUnits()=default
CharUnits - A default constructor.
bool operator==(const CharUnits &Other) const
llvm::MaybeAlign getAsMaybeAlign() const
getAsMaybeAlign - Returns Quantity as a valid llvm::Align or std::nullopt, Beware llvm::MaybeAlign as...
llvm::Align getAsAlign() const
getAsAlign - Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit b...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits One()
One - Construct a CharUnits quantity of one.
CharUnits operator%(QuantityType N) const
static CharUnits fromQuantity(llvm::Align Quantity)
fromQuantity - Construct a CharUnits quantity from an llvm::Align quantity.
bool operator>(const CharUnits &Other) const
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
bool operator<=(const CharUnits &Other) const
bool operator>=(const CharUnits &Other) const
bool isOne() const
isOne - Test whether the quantity equals one.
CharUnits operator+(const CharUnits &Other) const
CharUnits operator*(QuantityType N) const
CharUnits & operator+=(const CharUnits &Other)
CharUnits operator/(QuantityType N) const
bool isMultipleOf(CharUnits N) const
Test whether this is a multiple of the other value.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
CharUnits alignTo(const CharUnits &Align) const
alignTo - Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is ...
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
bool operator!=(const CharUnits &Other) const
CharUnits & operator/=(QuantityType N)
The JSON file list parser is used to communicate input to InstallAPI.
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
static clang::CharUnits getTombstoneKey()
static clang::CharUnits getEmptyKey()
static unsigned getHashValue(const clang::CharUnits &CU)
static bool isEqual(const clang::CharUnits &LHS, const clang::CharUnits &RHS)