GTIRB
v2.2.0
GrammaTech Intermediate Representation for Binaries: C++ API
|
Go to the documentation of this file.
45 constexpr
Addr() noexcept : Address{0} {}
55 constexpr
explicit operator value_type() const noexcept {
return Address; }
166 const Addr& B) noexcept {
172 return LHS.Address == RHS.Address;
182 return LHS.Address < RHS.Address;
187 return operator<(RHS, LHS);
192 return !operator<(RHS, LHS);
197 return !operator<(LHS, RHS);
201 value_type Address{0};
216 : First(Lower), Size(Upper - (Lower < Upper ? Lower : Upper)) {}
224 : First(Lower), Size(Count) {}
228 return First == RHS.First && Size == RHS.Size;
233 return First != RHS.First || Size != RHS.Size;
240 constexpr
Addr upper() const noexcept {
return First + Size; }
243 constexpr uint64_t
size() const noexcept {
return Size; }
253 template <
typename T> std::optional<uint64_t>
asOptionalSize(T X);
275 template <
typename T> std::optional<AddrRange>
addressRange(
const T& Object) {
276 if (std::optional<Addr> A = Object.getAddress()) {
277 if (std::optional<uint64_t>
S = Object.getSize()) {
294 template <
typename T> std::optional<Addr>
addressLimit(
const T& Object) {
295 auto A = Object.getAddress();
315 return Object.getAddress() <= Ea && addressLimit(Object) > Ea;
329 template <
typename CharT,
typename Traits>
330 std::basic_ostream<CharT, Traits>&
332 auto Flags = Stream.flags();
333 Stream << std::setbase(16) << std::showbase << static_cast<uint64_t>(A);
349 template <
typename CharT,
typename Traits>
350 std::basic_ostream<CharT, Traits>&
351 operator<<(std::basic_ostream<CharT, Traits>& Stream, std::optional<Addr> A) {
354 return Stream <<
"<none>";
362 template <>
struct hash<
gtirb::Addr> {
364 return std::hash<uint64_t>{}(
static_cast<uint64_t
>(A));
370 #endif // GTIRB_ADDR_H
constexpr bool operator==(const AddrRange &RHS) const noexcept
Equality operator for AddrRange.
Definition: Addr.hpp:227
constexpr friend bool operator<=(const Addr &LHS, const Addr &RHS) noexcept
Less-than-or-equal operator for Addr.
Definition: Addr.hpp:191
constexpr uint64_t size() const noexcept
Number of addresses in the range.
Definition: Addr.hpp:243
std::optional< Addr > addressLimit(const T &Object)
Exclusive upper limit of an object's address range.
Definition: Addr.hpp:294
uint64_t value_type
The underlying type used to represent an Addr object.
Definition: Addr.hpp:40
constexpr friend bool operator!=(const Addr &LHS, const Addr &RHS) noexcept
Inquality operator for Addr.
Definition: Addr.hpp:176
A range of addresses.
Definition: Addr.hpp:205
constexpr friend Addr operator+(value_type Offset, const Addr &A) noexcept
Binary + operator for integral offset + Addr.
Definition: Addr.hpp:121
A special class to store an Effective Address.
Definition: Addr.hpp:37
constexpr Addr & operator--() noexcept
Predecrement for Addr.
Definition: Addr.hpp:90
constexpr Addr operator--(int) noexcept
Postdecrement for Addr.
Definition: Addr.hpp:99
constexpr Addr & operator-=(value_type Offset) noexcept
Subtract-assign for Addr.
Definition: Addr.hpp:153
constexpr Addr upper() const noexcept
Exclusive upper bound of the address range.
Definition: Addr.hpp:240
std::enable_if_t< std::is_error_code_enum< E >::value||std::is_error_condition_enum< E >::value, bool > operator==(const ErrorOr< T > &Err, E Code)
Definition: ErrorOr.hpp:277
constexpr Addr() noexcept
Default constructor.
Definition: Addr.hpp:45
int64_t difference_type
The type used to represent a difference between two Addr objects.
Definition: Addr.hpp:42
Describes a location inside a node (byte interval, block, etc).
Definition: Offset.hpp:32
std::optional< AddrRange > addressRange(const T &Object)
Address range of an object.
Definition: Addr.hpp:275
constexpr friend bool operator>=(const Addr &LHS, const Addr &RHS) noexcept
Greater-than-or-equal operator for Addr.
Definition: Addr.hpp:196
#define GTIRB_EXPORT_API
This macro controls the visibility of exported symbols (i.e. classes) in shared libraries....
Definition: Export.hpp:52
Main namespace for the GTIRB API.
Definition: Addr.hpp:28
constexpr friend difference_type operator-(const Addr &A, const Addr &B) noexcept
Binary - operator for Addr - Addr.
Definition: Addr.hpp:165
constexpr Addr lower() const noexcept
Inclusive lower bound of the address range.
Definition: Addr.hpp:237
constexpr Addr operator++(int) noexcept
Postincrement for Addr.
Definition: Addr.hpp:81
std::optional< uint64_t > asOptionalSize(T X)
constexpr Addr operator+() const noexcept
Unary plus for Addr. This is a noop because Addr objects represent an unsigned address value.
Definition: Addr.hpp:61
constexpr Addr(value_type X) noexcept
Explicit conversion from value_type to Addr.
Definition: Addr.hpp:50
constexpr friend Addr operator+(const Addr &A, value_type Offset) noexcept
Binary + operator for Addr + integral offset.
Definition: Addr.hpp:111
constexpr friend Addr operator-(const Addr &A, value_type Offset) noexcept
Binary - operator for Addr - integral offset.
Definition: Addr.hpp:144
constexpr friend bool operator>(const Addr &LHS, const Addr &RHS) noexcept
Greater-than operator for Addr.
Definition: Addr.hpp:186
constexpr friend bool operator<(const Addr &LHS, const Addr &RHS) noexcept
Less-than operator for Addr.
Definition: Addr.hpp:181
constexpr Addr & operator+=(value_type Offset) noexcept
Add-assign for Addr.
Definition: Addr.hpp:130
constexpr bool operator!=(const AddrRange &RHS) const noexcept
Inequality operator for AddrRange.
Definition: Addr.hpp:232
constexpr AddrRange(Addr Lower, uint64_t Count) noexcept
Construct a range starting at Lower and containing a total of Count addresses.
Definition: Addr.hpp:223
constexpr AddrRange(Addr Lower, Addr Upper) noexcept
Construct a range starting at Lower, extending up to, but not including, Upper.
Definition: Addr.hpp:215
GTIRB_EXPORT_API std::ostream & operator<<(std::ostream &OS, const ConditionalEdge &CE)
bool containsAddr(const T &Object, Addr Ea)
Check: Does the specified object contain the specified address?
Definition: Addr.hpp:314
constexpr Addr & operator++() noexcept
Preincrement for Addr.
Definition: Addr.hpp:72
constexpr friend bool operator==(const Addr &LHS, const Addr &RHS) noexcept
Equality operator for Addr.
Definition: Addr.hpp:171
size_t operator()(const gtirb::Addr &A) const
Definition: Addr.hpp:363
constexpr Addr operator~() const noexcept
Unary complement for Addr. Flips the value of all bits in the address.
Definition: Addr.hpp:67