9#ifndef LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
10#define LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
19namespace ms_demangle {
28 struct AllocatorNode {
29 uint8_t *Buf =
nullptr;
32 AllocatorNode *Next =
nullptr;
35 void addNode(
size_t Capacity) {
36 AllocatorNode *NewHead =
new AllocatorNode;
37 NewHead->Buf =
new uint8_t[Capacity];
39 NewHead->Capacity = Capacity;
51 AllocatorNode *Next = Head->Next;
64 uint8_t *
P = Head->Buf + Head->Used;
67 if (Head->Used <= Head->Capacity)
68 return reinterpret_cast<char *
>(
P);
72 return reinterpret_cast<char *
>(Head->Buf);
75 template <
typename T,
typename... Args>
T *
allocArray(
size_t Count) {
76 size_t Size = Count *
sizeof(
T);
79 size_t P = (size_t)Head->Buf + Head->Used;
81 (((
size_t)
P +
alignof(
T) - 1) & ~(size_t)(
alignof(
T) - 1));
82 uint8_t *PP = (uint8_t *)AlignedP;
83 size_t Adjustment = AlignedP -
P;
85 Head->Used +=
Size + Adjustment;
86 if (Head->Used <= Head->Capacity)
87 return new (PP)
T[Count]();
91 return new (Head->Buf)
T[Count]();
94 template <
typename T,
typename... Args>
T *
alloc(Args &&... ConstructorArgs) {
95 constexpr size_t Size =
sizeof(
T);
98 size_t P = (size_t)Head->Buf + Head->Used;
100 (((
size_t)
P +
alignof(
T) - 1) & ~(size_t)(
alignof(
T) - 1));
101 uint8_t *PP = (uint8_t *)AlignedP;
102 size_t Adjustment = AlignedP -
P;
104 Head->Used +=
Size + Adjustment;
105 if (Head->Used <= Head->Capacity)
106 return new (PP)
T(std::forward<Args>(ConstructorArgs)...);
111 return new (Head->Buf)
T(std::forward<Args>(ConstructorArgs)...);
115 AllocatorNode *Head =
nullptr;
119 static constexpr size_t Max = 10;
160 SymbolNode *demangleEncodedSymbol(std::string_view &MangledName,
162 SymbolNode *demangleDeclarator(std::string_view &MangledName);
163 SymbolNode *demangleMD5Name(std::string_view &MangledName);
164 SymbolNode *demangleTypeinfoName(std::string_view &MangledName);
170 Qualifiers demanglePointerExtQualifiers(std::string_view &MangledName);
173 TypeNode *demangleType(std::string_view &MangledName,
176 CustomTypeNode *demangleCustomType(std::string_view &MangledName);
177 TagTypeNode *demangleClassType(std::string_view &MangledName);
179 PointerTypeNode *demangleMemberPointerType(std::string_view &MangledName);
183 ArrayTypeNode *demangleArrayType(std::string_view &MangledName);
185 NodeArrayNode *demangleFunctionParameterList(std::string_view &MangledName,
187 NodeArrayNode *demangleTemplateParameterList(std::string_view &MangledName);
189 std::pair<uint64_t, bool> demangleNumber(std::string_view &MangledName);
190 uint64_t demangleUnsigned(std::string_view &MangledName);
191 int64_t demangleSigned(std::string_view &MangledName);
193 void memorizeString(std::string_view s);
197 std::string_view copyString(std::string_view Borrowed);
200 demangleFullyQualifiedTypeName(std::string_view &MangledName);
202 demangleFullyQualifiedSymbolName(std::string_view &MangledName);
204 IdentifierNode *demangleUnqualifiedTypeName(std::string_view &MangledName,
206 IdentifierNode *demangleUnqualifiedSymbolName(std::string_view &MangledName,
211 IdentifierNode *demangleNameScopePiece(std::string_view &MangledName);
215 demangleTemplateInstantiationName(std::string_view &MangledName,
219 IdentifierNode *demangleFunctionIdentifierCode(std::string_view &MangledName);
221 demangleFunctionIdentifierCode(std::string_view &MangledName,
224 demangleStructorIdentifier(std::string_view &MangledName,
bool IsDestructor);
226 demangleConversionOperatorIdentifier(std::string_view &MangledName);
228 demangleLiteralOperatorIdentifier(std::string_view &MangledName);
230 SymbolNode *demangleSpecialIntrinsic(std::string_view &MangledName);
232 demangleSpecialTableSymbolNode(std::string_view &MangledName,
235 demangleLocalStaticGuard(std::string_view &MangledName,
bool IsThread);
237 std::string_view &MangledName,
238 std::string_view VariableName);
241 std::string_view &MangledName);
248 demangleAnonymousNamespaceName(std::string_view &MangledName);
250 demangleLocallyScopedNamePiece(std::string_view &MangledName);
252 demangleStringLiteral(std::string_view &MangledName);
255 std::string_view demangleSimpleString(std::string_view &MangledName,
258 FuncClass demangleFunctionClass(std::string_view &MangledName);
259 CallingConv demangleCallingConvention(std::string_view &MangledName);
260 StorageClass demangleVariableStorageClass(std::string_view &MangledName);
261 bool demangleThrowSpecification(std::string_view &MangledName);
262 wchar_t demangleWcharLiteral(std::string_view &MangledName);
263 uint8_t demangleCharLiteral(std::string_view &MangledName);
265 std::pair<Qualifiers, bool> demangleQualifiers(std::string_view &MangledName);
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
T * alloc(Args &&... ConstructorArgs)
char * allocUnalignedBuffer(size_t Size)
ArenaAllocator & operator=(const ArenaAllocator &)=delete
T * allocArray(size_t Count)
ArenaAllocator(const ArenaAllocator &)=delete
TagTypeNode * parseTagUniqueName(std::string_view &MangledName)
virtual ~Demangler()=default
void dumpBackReferences()
FunctionIdentifierCodeGroup
constexpr size_t AllocUnit
This is an optimization pass for GlobalISel generic memory operations.
static constexpr size_t Max
NamedIdentifierNode * Names[Max]
TypeNode * FunctionParams[Max]
size_t FunctionParamCount