9#ifndef LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
10#define LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
21namespace ms_demangle {
30 struct AllocatorNode {
34 AllocatorNode *Next =
nullptr;
37 void addNode(
size_t Capacity) {
38 AllocatorNode *NewHead =
new AllocatorNode;
39 NewHead->Buf =
new uint8_t[Capacity];
41 NewHead->Capacity = Capacity;
53 AllocatorNode *Next = Head->Next;
69 if (Head->Used <= Head->Capacity)
70 return reinterpret_cast<char *
>(
P);
74 return reinterpret_cast<char *
>(Head->Buf);
77 template <
typename T,
typename... Args>
T *
allocArray(
size_t Count) {
78 size_t Size = Count *
sizeof(
T);
81 size_t P = (size_t)Head->Buf + Head->Used;
83 (((
size_t)
P +
alignof(
T) - 1) & ~(size_t)(
alignof(
T) - 1));
85 size_t Adjustment = AlignedP -
P;
87 Head->Used +=
Size + Adjustment;
88 if (Head->Used <= Head->Capacity)
89 return new (PP)
T[Count]();
93 return new (Head->Buf)
T[Count]();
96 template <
typename T,
typename... Args>
T *
alloc(Args &&... ConstructorArgs) {
97 constexpr size_t Size =
sizeof(
T);
100 size_t P = (size_t)Head->Buf + Head->Used;
102 (((
size_t)
P +
alignof(
T) - 1) & ~(size_t)(
alignof(
T) - 1));
104 size_t Adjustment = AlignedP -
P;
106 Head->Used +=
Size + Adjustment;
107 if (Head->Used <= Head->Capacity)
108 return new (PP)
T(std::forward<Args>(ConstructorArgs)...);
113 return new (Head->Buf)
T(std::forward<Args>(ConstructorArgs)...);
117 AllocatorNode *Head =
nullptr;
121 static constexpr size_t Max = 10;
146 friend std::optional<size_t>
165 SymbolNode *demangleEncodedSymbol(std::string_view &MangledName,
167 SymbolNode *demangleDeclarator(std::string_view &MangledName);
168 SymbolNode *demangleMD5Name(std::string_view &MangledName);
169 SymbolNode *demangleTypeinfoName(std::string_view &MangledName);
175 Qualifiers demanglePointerExtQualifiers(std::string_view &MangledName);
177 bool isMemberPointer(std::string_view MangledName,
bool &
Error);
179 std::optional<PointerAuthQualifierNode::ArgArray>
180 demanglePointerAuthQualifier(std::string_view &MangledName);
183 createPointerAuthQualifier(std::string_view &MangledName);
186 TypeNode *demangleType(std::string_view &MangledName,
189 CustomTypeNode *demangleCustomType(std::string_view &MangledName);
190 TagTypeNode *demangleClassType(std::string_view &MangledName);
192 PointerTypeNode *demangleMemberPointerType(std::string_view &MangledName);
196 ArrayTypeNode *demangleArrayType(std::string_view &MangledName);
198 NodeArrayNode *demangleFunctionParameterList(std::string_view &MangledName,
200 NodeArrayNode *demangleTemplateParameterList(std::string_view &MangledName);
202 std::pair<uint64_t, bool> demangleNumber(std::string_view &MangledName);
203 uint64_t demangleUnsigned(std::string_view &MangledName);
204 int64_t demangleSigned(std::string_view &MangledName);
206 void memorizeString(std::string_view s);
210 std::string_view copyString(std::string_view Borrowed);
213 demangleFullyQualifiedTypeName(std::string_view &MangledName);
215 demangleFullyQualifiedSymbolName(std::string_view &MangledName);
217 IdentifierNode *demangleUnqualifiedTypeName(std::string_view &MangledName,
219 IdentifierNode *demangleUnqualifiedSymbolName(std::string_view &MangledName,
224 IdentifierNode *demangleNameScopePiece(std::string_view &MangledName);
228 demangleTemplateInstantiationName(std::string_view &MangledName,
232 IdentifierNode *demangleFunctionIdentifierCode(std::string_view &MangledName);
234 demangleFunctionIdentifierCode(std::string_view &MangledName,
237 demangleStructorIdentifier(std::string_view &MangledName,
bool IsDestructor);
239 demangleConversionOperatorIdentifier(std::string_view &MangledName);
241 demangleLiteralOperatorIdentifier(std::string_view &MangledName);
243 SymbolNode *demangleSpecialIntrinsic(std::string_view &MangledName);
245 demangleSpecialTableSymbolNode(std::string_view &MangledName,
248 demangleLocalStaticGuard(std::string_view &MangledName,
bool IsThread);
250 std::string_view &MangledName,
251 std::string_view VariableName);
254 std::string_view &MangledName);
261 demangleAnonymousNamespaceName(std::string_view &MangledName);
263 demangleLocallyScopedNamePiece(std::string_view &MangledName);
265 demangleStringLiteral(std::string_view &MangledName);
268 std::string_view demangleSimpleString(std::string_view &MangledName,
271 FuncClass demangleFunctionClass(std::string_view &MangledName);
272 CallingConv demangleCallingConvention(std::string_view &MangledName);
273 StorageClass demangleVariableStorageClass(std::string_view &MangledName);
274 bool demangleThrowSpecification(std::string_view &MangledName);
275 wchar_t demangleWcharLiteral(std::string_view &MangledName);
276 uint8_t demangleCharLiteral(std::string_view &MangledName);
278 std::pair<Qualifiers, bool> demangleQualifiers(std::string_view &MangledName);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define DEMANGLE_ABI
DEMANGLE_ABI is the export/visibility macro used to mark symbols delcared in llvm/Demangle as exporte...
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
DEMANGLE_ABI TagTypeNode * parseTagUniqueName(std::string_view &MangledName)
virtual ~Demangler()=default
DEMANGLE_ABI void dumpBackReferences()
FunctionIdentifierCodeGroup
constexpr size_t AllocUnit
This is an optimization pass for GlobalISel generic memory operations.
DEMANGLE_ABI std::optional< size_t > getArm64ECInsertionPointInMangledName(std::string_view MangledName)
static constexpr size_t Max
NamedIdentifierNode * Names[Max]
TypeNode * FunctionParams[Max]
size_t FunctionParamCount