12 #ifndef LLVM_DEMANGLE_UTILITY_H 13 #define LLVM_DEMANGLE_UTILITY_H 27 size_t CurrentPosition;
28 size_t BufferCapacity;
32 if (N + CurrentPosition >= BufferCapacity) {
34 if (BufferCapacity < N + CurrentPosition)
35 BufferCapacity = N + CurrentPosition;
36 Buffer =
static_cast<char *
>(std::realloc(Buffer, BufferCapacity));
37 if (Buffer ==
nullptr)
42 void writeUnsigned(uint64_t N,
bool isNeg =
false) {
53 *--TempPtr =
'0' +
char(N % 10);
65 : Buffer(StartBuf), CurrentPosition(0), BufferCapacity(Size) {}
67 void reset(
char *Buffer_,
size_t BufferCapacity_) {
70 BufferCapacity = BufferCapacity_;
84 CurrentPosition +=
Size;
90 Buffer[CurrentPosition++] =
C;
100 writeUnsigned(static_cast<unsigned long long>(-N),
true);
102 writeUnsigned(static_cast<unsigned long long>(N));
107 writeUnsigned(N,
false);
112 return this->operator<<(static_cast<long long>(
N));
116 return this->operator<<(static_cast<unsigned long long>(
N));
120 return this->operator<<(static_cast<long long>(
N));
124 return this->operator<<(static_cast<unsigned long long>(
N));
131 return CurrentPosition ? Buffer[CurrentPosition - 1] :
'\0';
134 bool empty()
const {
return CurrentPosition == 0; }
144 bool ShouldRestore =
true;
150 : Restore(Restore_), OriginalValue(Restore) {
151 Restore = std::move(NewVal);
155 Restore = std::move(OriginalValue);
161 if (!Force && !ShouldRestore)
164 Restore = std::move(OriginalValue);
165 ShouldRestore =
false;
175 if (Buf ==
nullptr) {
176 Buf =
static_cast<char *
>(std::malloc(InitSize));
179 BufferSize = InitSize;
183 S.
reset(Buf, BufferSize);
const_iterator end(StringRef path)
Get end iterator over path.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
OutputStream & operator+=(char C)
OutputStream & operator<<(char C)
OutputStream & operator<<(unsigned int N)
OutputStream & operator<<(long N)
unsigned CurrentPackIndex
If a ParameterPackExpansion (or similar type) is encountered, the offset into the pack that we're cur...
void restoreNow(bool Force)
const char * begin() const
OutputStream & operator+=(StringView R)
OutputStream & operator<<(long long N)
OutputStream & operator<<(int N)
OutputStream(char *StartBuf, size_t Size)
void shouldRestore(bool ShouldRestore_)
size_t getCurrentPosition() const
SwapAndRestore(T &Restore_)
OutputStream & operator<<(unsigned long N)
void setCurrentPosition(size_t NewPos)
SwapAndRestore(T &Restore_, T NewVal)
size_t getBufferCapacity()
OutputStream & operator<<(unsigned long long N)
OutputStream & operator<<(StringView R)
bool initializeOutputStream(char *Buf, size_t *N, OutputStream &S, size_t InitSize)
void reset(char *Buffer_, size_t BufferCapacity_)