@@ -29,7 +29,7 @@ class Function;
29
29
// / Pointer into the code segment.
30
30
class CodePtr final {
31
31
public:
32
- CodePtr () : Ptr( nullptr ) {}
32
+ CodePtr () = default ;
33
33
34
34
CodePtr &operator +=(int32_t Offset) {
35
35
Ptr += Offset;
@@ -45,11 +45,16 @@ class CodePtr final {
45
45
assert (Ptr != nullptr && " Invalid code pointer" );
46
46
return CodePtr (Ptr - RHS);
47
47
}
48
+ CodePtr operator +(ssize_t RHS) const {
49
+ assert (Ptr != nullptr && " Invalid code pointer" );
50
+ return CodePtr (Ptr + RHS);
51
+ }
48
52
49
53
bool operator !=(const CodePtr &RHS) const { return Ptr != RHS.Ptr ; }
50
54
const std::byte *operator *() const { return Ptr; }
51
-
52
- operator bool () const { return Ptr; }
55
+ explicit operator bool () const { return Ptr; }
56
+ bool operator <=(const CodePtr &RHS) const { return Ptr <= RHS.Ptr ; }
57
+ bool operator >=(const CodePtr &RHS) const { return Ptr >= RHS.Ptr ; }
53
58
54
59
// / Reads data and advances the pointer.
55
60
template <typename T> std::enable_if_t <!std::is_pointer<T>::value, T> read () {
@@ -65,7 +70,7 @@ class CodePtr final {
65
70
// / Constructor used by Function to generate pointers.
66
71
CodePtr (const std::byte *Ptr) : Ptr(Ptr) {}
67
72
// / Pointer into the code owned by a function.
68
- const std::byte *Ptr;
73
+ const std::byte *Ptr = nullptr ;
69
74
};
70
75
71
76
// / Describes the statement/declaration an opcode was generated from.
0 commit comments