1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

llvm-undname: More coverage-related cleanups

- The loop in demangleFunctionParameterList() only exits
  on Error, @, and Z. All 3 cases were handled, so the
  rest of the function is DEMANGLE_UNREACHABLE.

- The loop in demangleTemplateParameterList() always returns
  on Error, so there's no need to check for that in the loop
  header and after the loop.

- Add test cases for invalid function parameter manglings.

- Add a (redundant) test case for a simple template parameter
  list mangling.

- Add a test case pointing out that varargs functions aren't
  demangled correctly.

llvm-svn: 362540
This commit is contained in:
Nico Weber 2019-06-04 18:49:05 +00:00
parent 89eee05f25
commit 0df40efc5e
4 changed files with 25 additions and 11 deletions

View File

@ -2093,7 +2093,7 @@ ArrayTypeNode *Demangler::demangleArrayType(StringView &MangledName) {
return ATy;
}
// Reads a function or a template parameters.
// Reads a function's parameters.
NodeArrayNode *
Demangler::demangleFunctionParameterList(StringView &MangledName) {
// Empty parameter list.
@ -2157,8 +2157,7 @@ Demangler::demangleFunctionParameterList(StringView &MangledName) {
return NA;
}
Error = true;
return nullptr;
DEMANGLE_UNREACHABLE;
}
NodeArrayNode *
@ -2167,7 +2166,7 @@ Demangler::demangleTemplateParameterList(StringView &MangledName) {
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
@ -2278,15 +2277,14 @@ Demangler::demangleTemplateParameterList(StringView &MangledName) {
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() {

View File

@ -100,6 +100,16 @@
; 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

View File

@ -38,6 +38,10 @@
?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)

View File

@ -4,6 +4,8 @@
; CHECK-NOT: Invalid mangled name
?f@@3V?$C@H@@A
; CHECK: class C<int> f
??0?$Class@VTypename@@@@QAE@XZ
; CHECK: __thiscall Class<class Typename>::Class<class Typename>(void)