LLVM: include/llvm/ADT/RewriteRope.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_ADT_REWRITEROPE_H
14#define LLVM_ADT_REWRITEROPE_H
15
19#include
20#include
21#include
22#include
23
24namespace llvm {
25
26
27
28
29
30
31
32
33
37
39
41 assert(RefCount > 0 && "Reference count is already zero.");
43 delete[] (char *)this;
44 }
45};
46
47
48
49
50
51
52
53
54
55
56
57
58
78
79
80
81
82
83
84
85
86
88
89 const void *CurNode = nullptr;
90
91
92
93 const RopePiece *CurPiece = nullptr;
94
95
96 unsigned CurChar = 0;
97
98public:
104
107
108 char operator*() const { return (*CurPiece)[CurChar]; }
109
111 return CurPiece == RHS.CurPiece && CurChar == RHS.CurChar;
112 }
116
118 if (CurChar + 1 < CurPiece->size())
119 ++CurChar;
120 else
122 return *this;
123 }
124
127 ++*this;
128 return tmp;
129 }
130
134
136};
137
138
139
140
141
143 void *Root;
144
145public:
150
152
156 unsigned empty() const { return size() == 0; }
157
159
161
163};
164
165
166
167
168
169
170
171
174
175
176
178 enum { AllocChunkSize = 4080 };
179 unsigned AllocOffs = AllocChunkSize;
180
181public:
184
185
186
188
191
194 unsigned size() const { return Chunks.size(); }
195
196 void clear() { Chunks.clear(); }
197
198 void assign(const char *Start, const char *End) {
200 if (Start != End)
201 Chunks.insert(0, MakeRopeString(Start, End));
202 }
203
204 void insert(unsigned Offset, const char *Start, const char *End) {
206 if (Start == End)
207 return;
208 Chunks.insert(Offset, MakeRopeString(Start, End));
209 }
210
212 assert(Offset + NumBytes <= size() && "Invalid region to erase!");
213 if (NumBytes == 0)
214 return;
215 Chunks.erase(Offset, NumBytes);
216 }
217
218private:
219 LLVM_ABI RopePiece MakeRopeString(const char *Start, const char *End);
220};
221
222}
223
224#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the RefCountedBase, ThreadSafeRefCountedBase, and IntrusiveRefCntPtr classes.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
unsigned size() const
Definition RewriteRope.h:194
RewriteRope & operator=(const RewriteRope &)=delete
void insert(unsigned Offset, const char *Start, const char *End)
Definition RewriteRope.h:204
RopePieceBTree::iterator iterator
Definition RewriteRope.h:189
iterator end() const
Definition RewriteRope.h:193
RewriteRope(const RewriteRope &RHS)
Definition RewriteRope.h:183
void clear()
Definition RewriteRope.h:196
RopePieceBTree::iterator const_iterator
Definition RewriteRope.h:190
void erase(unsigned Offset, unsigned NumBytes)
Definition RewriteRope.h:211
iterator begin() const
Definition RewriteRope.h:192
void assign(const char *Start, const char *End)
Definition RewriteRope.h:198
RopePieceBTreeIterator - This class provides read-only forward iteration over bytes that are in a Rop...
Definition RewriteRope.h:87
char operator*() const
Definition RewriteRope.h:108
RopePieceBTreeIterator & operator++()
Definition RewriteRope.h:117
bool operator==(const RopePieceBTreeIterator &RHS) const
Definition RewriteRope.h:110
value_type & reference
Definition RewriteRope.h:103
RopePieceBTreeIterator()=default
std::forward_iterator_tag iterator_category
Definition RewriteRope.h:99
std::ptrdiff_t difference_type
Definition RewriteRope.h:101
value_type * pointer
Definition RewriteRope.h:102
LLVM_ABI void MoveToNextPiece()
RopePieceBTreeIterator operator++(int)
Definition RewriteRope.h:125
const char value_type
Definition RewriteRope.h:100
llvm::StringRef piece() const
Definition RewriteRope.h:131
bool operator!=(const RopePieceBTreeIterator &RHS) const
Definition RewriteRope.h:113
Definition RewriteRope.h:142
LLVM_ABI ~RopePieceBTree()
iterator end() const
Definition RewriteRope.h:154
LLVM_ABI unsigned size() const
RopePieceBTreeIterator iterator
Definition RewriteRope.h:151
LLVM_ABI void insert(unsigned Offset, const RopePiece &R)
LLVM_ABI void erase(unsigned Offset, unsigned NumBytes)
iterator begin() const
Definition RewriteRope.h:153
RopePieceBTree & operator=(const RopePieceBTree &)=delete
LLVM_ABI RopePieceBTree()
unsigned empty() const
Definition RewriteRope.h:156
StringRef - Represent a constant reference to a string, i.e.
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
RopePiece - This class represents a view into a RopeRefCountString object.
Definition RewriteRope.h:59
unsigned EndOffs
Definition RewriteRope.h:62
unsigned StartOffs
Definition RewriteRope.h:61
char & operator[](unsigned Offset)
Definition RewriteRope.h:72
RopePiece(llvm::IntrusiveRefCntPtr< RopeRefCountString > Str, unsigned Start, unsigned End)
Definition RewriteRope.h:65
unsigned size() const
Definition RewriteRope.h:76
const char & operator[](unsigned Offset) const
Definition RewriteRope.h:69
llvm::IntrusiveRefCntPtr< RopeRefCountString > StrData
Definition RewriteRope.h:60
RopeRefCountString - This struct is allocated with 'new char[]' from the heap, and represents a refer...
Definition RewriteRope.h:34
void Release()
Definition RewriteRope.h:40
void Retain()
Definition RewriteRope.h:38
unsigned RefCount
Definition RewriteRope.h:35
char Data[1]
Definition RewriteRope.h:36