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"
70 Quantity +=
Other.Quantity;
79 Quantity -=
Other.Quantity;
101 bool isZero()
const {
return Quantity == 0; }
104 bool isOne()
const {
return Quantity == 1; }
115 return Quantity > 0 && llvm::isPowerOf2_64(Quantity);
138 return Quantity /
Other.Quantity;
159 llvm::Align
getAsAlign()
const {
return llvm::Align(Quantity); }
165 return llvm::MaybeAlign(Quantity);
172 return CharUnits(llvm::alignTo(Quantity, Align.Quantity));
178 assert(Quantity != 0 &&
"offsetting from unknown alignment?");
179 return CharUnits(llvm::MinAlign(Quantity, offset.Quantity));
201template<>
struct DenseMapInfo<
clang::CharUnits> {
204 return DenseMapInfo<clang::CharUnits::QuantityType>::getHashValue(Quantity);
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, clang::CharUnits CU)
This is an opaque type for sizes expressed in character units.
CharUnits operator-() const
bool isPowerOfTwo() const
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
Test whether the quantity is less than zero.
CharUnits & operator+=(CharUnits Other)
CharUnits & operator*=(QuantityType N)
bool operator!=(CharUnits Other) const
CharUnits & operator-=(CharUnits Other)
CharUnits operator%(CharUnits Other) const
bool isPositive() const
Test whether the quantity is greater than zero.
bool isZero() const
Test whether the quantity equals zero.
CharUnits operator++(int)
bool operator==(CharUnits Other) const
CharUnits()=default
A default constructor.
CharUnits alignTo(CharUnits Align) const
Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is a multiple...
llvm::MaybeAlign getAsMaybeAlign() const
Returns Quantity as a valid llvm::Align or std::nullopt, Beware llvm::MaybeAlign assumes power of two...
llvm::Align getAsAlign() const
Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit bytes.
QuantityType operator/(CharUnits Other) const
QuantityType getQuantity() const
Get the raw integer representation of this quantity.
static CharUnits One()
Construct a CharUnits quantity of one.
CharUnits operator%(QuantityType N) const
CharUnits operator+(CharUnits Other) const
static CharUnits fromQuantity(llvm::Align Quantity)
Construct a CharUnits quantity from an llvm::Align quantity.
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 isOne() const
Test whether the quantity equals one.
CharUnits operator-(CharUnits Other) const
CharUnits operator*(QuantityType N) const
bool operator<=(CharUnits Other) const
bool operator>=(CharUnits Other) const
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)
Construct a CharUnits quantity from a raw integer type.
bool operator<(CharUnits Other) const
static CharUnits Zero()
Construct a CharUnits quantity of zero.
bool operator>(CharUnits Other) const
CharUnits operator--(int)
CharUnits & operator/=(QuantityType N)
Top level wrappers for InstallAPI frontend operations.
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
static unsigned getHashValue(clang::CharUnits CU)
static bool isEqual(clang::CharUnits LHS, clang::CharUnits RHS)