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_;
78 if (!StartBuf || !Size) {
79 StartBuf =
static_cast<char *
>(std::malloc(AllocSize));
80 if (StartBuf ==
nullptr)
85 Result.
reset(StartBuf, *Size);
99 std::memmove(Buffer + CurrentPosition, R.
begin(),
Size);
100 CurrentPosition +=
Size;
106 Buffer[CurrentPosition++] =
C;
116 writeUnsigned(static_cast<unsigned long long>(-N),
true);
118 writeUnsigned(static_cast<unsigned long long>(N));
123 writeUnsigned(N,
false);
128 return this->operator<<(static_cast<long long>(
N));
132 return this->operator<<(static_cast<unsigned long long>(
N));
136 return this->operator<<(static_cast<long long>(
N));
140 return this->operator<<(static_cast<unsigned long long>(
N));
147 return CurrentPosition ? Buffer[CurrentPosition - 1] :
'\0';
150 bool empty()
const {
return CurrentPosition == 0; }
160 bool ShouldRestore =
true;
166 : Restore(Restore_), OriginalValue(Restore) {
167 Restore = std::move(NewVal);
171 Restore = std::move(OriginalValue);
177 if (!Force && !ShouldRestore)
180 Restore = std::move(OriginalValue);
181 ShouldRestore =
false;
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)
static OutputStream create(char *StartBuf, size_t *Size, size_t AllocSize)
Create an OutputStream from a buffer and a size.
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)
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
void reset(char *Buffer_, size_t BufferCapacity_)