9#ifndef LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
10#define LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
20namespace ms_demangle {
29 struct AllocatorNode {
33 AllocatorNode *Next =
nullptr;
36 void addNode(
size_t Capacity) {
37 AllocatorNode *NewHead =
new AllocatorNode;
38 NewHead->Buf =
new uint8_t[Capacity];
40 NewHead->Capacity = Capacity;
52 AllocatorNode *Next = Head->Next;
68 if (Head->Used <= Head->Capacity)
69 return reinterpret_cast<char *
>(
P);
73 return reinterpret_cast<char *
>(Head->Buf);
76 template <
typename T,
typename... Args>
T *
allocArray(
size_t Count) {
77 size_t Size = Count *
sizeof(
T);
80 size_t P = (size_t)Head->Buf + Head->Used;
82 (((
size_t)
P +
alignof(
T) - 1) & ~(size_t)(
alignof(
T) - 1));
84 size_t Adjustment = AlignedP -
P;
86 Head->Used +=
Size + Adjustment;
87 if (Head->Used <= Head->Capacity)
88 return new (PP)
T[Count]();
92 return new (Head->Buf)
T[Count]();
95 template <
typename T,
typename... Args>
T *
alloc(Args &&... ConstructorArgs) {
96 constexpr size_t Size =
sizeof(
T);
99 size_t P = (size_t)Head->Buf + Head->Used;
101 (((
size_t)
P +
alignof(
T) - 1) & ~(size_t)(
alignof(
T) - 1));
103 size_t Adjustment = AlignedP -
P;
105 Head->Used +=
Size + Adjustment;
106 if (Head->Used <= Head->Capacity)
107 return new (PP)
T(std::forward<Args>(ConstructorArgs)...);
112 return new (Head->Buf)
T(std::forward<Args>(ConstructorArgs)...);
116 AllocatorNode *Head =
nullptr;
120 static constexpr size_t Max = 10;
145 friend std::optional<size_t>
164 SymbolNode *demangleEncodedSymbol(std::string_view &MangledName,
166 SymbolNode *demangleDeclarator(std::string_view &MangledName);
167 SymbolNode *demangleMD5Name(std::string_view &MangledName);
168 SymbolNode *demangleTypeinfoName(std::string_view &MangledName);
174 Qualifiers demanglePointerExtQualifiers(std::string_view &MangledName);
177 TypeNode *demangleType(std::string_view &MangledName,
180 CustomTypeNode *demangleCustomType(std::string_view &MangledName);
181 TagTypeNode *demangleClassType(std::string_view &MangledName);
183 PointerTypeNode *demangleMemberPointerType(std::string_view &MangledName);
187 ArrayTypeNode *demangleArrayType(std::string_view &MangledName);
189 NodeArrayNode *demangleFunctionParameterList(std::string_view &MangledName,
191 NodeArrayNode *demangleTemplateParameterList(std::string_view &MangledName);
193 std::pair<uint64_t, bool> demangleNumber(std::string_view &MangledName);
194 uint64_t demangleUnsigned(std::string_view &MangledName);
195 int64_t demangleSigned(std::string_view &MangledName);
197 void memorizeString(std::string_view s);
201 std::string_view copyString(std::string_view Borrowed);
204 demangleFullyQualifiedTypeName(std::string_view &MangledName);
206 demangleFullyQualifiedSymbolName(std::string_view &MangledName);
208 IdentifierNode *demangleUnqualifiedTypeName(std::string_view &MangledName,
210 IdentifierNode *demangleUnqualifiedSymbolName(std::string_view &MangledName,
215 IdentifierNode *demangleNameScopePiece(std::string_view &MangledName);
219 demangleTemplateInstantiationName(std::string_view &MangledName,
223 IdentifierNode *demangleFunctionIdentifierCode(std::string_view &MangledName);
225 demangleFunctionIdentifierCode(std::string_view &MangledName,
228 demangleStructorIdentifier(std::string_view &MangledName,
bool IsDestructor);
230 demangleConversionOperatorIdentifier(std::string_view &MangledName);
232 demangleLiteralOperatorIdentifier(std::string_view &MangledName);
234 SymbolNode *demangleSpecialIntrinsic(std::string_view &MangledName);
236 demangleSpecialTableSymbolNode(std::string_view &MangledName,
239 demangleLocalStaticGuard(std::string_view &MangledName,
bool IsThread);
241 std::string_view &MangledName,
242 std::string_view VariableName);
245 std::string_view &MangledName);
252 demangleAnonymousNamespaceName(std::string_view &MangledName);
254 demangleLocallyScopedNamePiece(std::string_view &MangledName);
256 demangleStringLiteral(std::string_view &MangledName);
259 std::string_view demangleSimpleString(std::string_view &MangledName,
262 FuncClass demangleFunctionClass(std::string_view &MangledName);
263 CallingConv demangleCallingConvention(std::string_view &MangledName);
264 StorageClass demangleVariableStorageClass(std::string_view &MangledName);
265 bool demangleThrowSpecification(std::string_view &MangledName);
266 wchar_t demangleWcharLiteral(std::string_view &MangledName);
267 uint8_t demangleCharLiteral(std::string_view &MangledName);
269 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.
std::optional< size_t > getArm64ECInsertionPointInMangledName(std::string_view MangledName)
static constexpr size_t Max
NamedIdentifierNode * Names[Max]
TypeNode * FunctionParams[Max]
size_t FunctionParamCount