return ATy;
}
-// Reads a function or a template parameters.
+// Reads a function's parameters.
NodeArrayNode *
Demangler::demangleFunctionParameterList(StringView &MangledName) {
// Empty parameter list.
return NA;
}
- Error = true;
- return nullptr;
+ DEMANGLE_UNREACHABLE;
}
NodeArrayNode *
NodeList **Current = &Head;
size_t Count = 0;
- while (!Error && !MangledName.startsWith('@')) {
+ while (!MangledName.startsWith('@')) {
if (MangledName.consumeFront("$S") || MangledName.consumeFront("$$V") ||
MangledName.consumeFront("$$$V") || MangledName.consumeFront("$$Z")) {
// parameter pack separator
Current = &TP.Next;
}
- if (Error)
- return nullptr;
+ // The loop above returns nullptr on Error.
+ assert(!Error);
// Template parameter lists cannot be variadic, so it can only be terminated
- // by @.
- if (MangledName.consumeFront('@'))
- return nodeListToNodeArray(Arena, Head, Count);
- Error = true;
- return nullptr;
+ // by @ (as opposed to 'Z' in the function parameter case).
+ assert(MangledName.startsWith('@')); // The above loop exits only on '@'.
+ MangledName.consumeFront('@');
+ return nodeListToNodeArray(Arena, Head, Count);
}
void Demangler::dumpBackReferences() {
; CHECK-NEXT: ??__E?Foo@@YAXXZ
; CHECK-NEXT: error: Invalid mangled name
+?foo@@YAH0@Z
+; CHECK-EMPTY:
+; CHECK-NEXT: ?foo@@YAH0@Z
+; CHECK-NEXT: error: Invalid mangled name
+
+?foo@@YAHH
+; CHECK-EMPTY:
+; CHECK-NEXT: ?foo@@YAHH
+; CHECK-NEXT: error: Invalid mangled name
+
??8@8
; CHECK-EMPTY:
; CHECK-NEXT: ??8@8
?x@@YAXMH@Z
; CHECK: void __cdecl x(float, int)
+?x@@YAXMHZZ
+; FIXME: This should be `(float, int, ...)`
+; CHECK: void __cdecl x(float, int)
+
?x@@3P6AHMNH@ZEA
; CHECK: int (__cdecl *x)(float, double, int)