clang: include/clang/AST/CharUnits.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_CLANG_AST_CHARUNITS_H
14#define LLVM_CLANG_AST_CHARUNITS_H
15
16#include "llvm/ADT/DenseMapInfo.h"
17#include "llvm/Support/Alignment.h"
18#include "llvm/Support/DataTypes.h"
19#include "llvm/Support/MathExtras.h"
20
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
39 public:
41
42 private:
44
46
47 public:
48
49
51
52
55 }
56
57
60 }
61
62
65 }
66
67
68
70 return CharUnits(Quantity.value());
71 }
72
73
75 Quantity += Other.Quantity;
76 return *this;
77 }
79 ++Quantity;
80 return *this;
81 }
84 }
86 Quantity -= Other.Quantity;
87 return *this;
88 }
90 --Quantity;
91 return *this;
92 }
95 }
96
97
99 return Quantity == Other.Quantity;
100 }
102 return Quantity != Other.Quantity;
103 }
104
105
107 return Quantity < Other.Quantity;
108 }
110 return Quantity <= Other.Quantity;
111 }
113 return Quantity > Other.Quantity;
114 }
116 return Quantity >= Other.Quantity;
117 }
118
119
120
121
122 bool isZero() const { return Quantity == 0; }
123
124
125 bool isOne() const { return Quantity == 1; }
126
127
129
130
132
133
134
136 return (Quantity & -Quantity) == Quantity;
137 }
138
139
140
141
142
144 return (*this % N) == 0;
145 }
146
147
150 }
152 Quantity *= N;
153 return *this;
154 }
157 }
159 Quantity /= N;
160 return *this;
161 }
163 return Quantity / Other.Quantity;
164 }
167 }
169 return Quantity % Other.Quantity;
170 }
173 }
176 }
179 }
180
181
182
183
184
186
187
188
189 llvm::Align getAsAlign() const { return llvm::Align(Quantity); }
190
191
192
193
195 return llvm::MaybeAlign(Quantity);
196 }
197
198
199
200
202 return CharUnits(llvm::alignTo(Quantity, Align.Quantity));
203 }
204
205
206
208 assert(Quantity != 0 && "offsetting from unknown alignment?");
209 return CharUnits(llvm::MinAlign(Quantity, offset.Quantity));
210 }
211
212
213
215
216
217
219 }
220
221
222 };
223}
224
227 return CU * Scale;
228}
229
230namespace llvm {
231
232template<> struct DenseMapInfo<clang::CharUnits> {
235 DenseMapInfoclang::CharUnits::QuantityType::getEmptyKey();
236
238 }
239
242 DenseMapInfoclang::CharUnits::QuantityType::getTombstoneKey();
243
245 }
246
249 return DenseMapInfoclang::CharUnits::QuantityType::getHashValue(Quantity);
250 }
251
254 return LHS == RHS;
255 }
256};
257
258}
259
260#endif
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)