[llvm] r362540 - llvm-undname: More coverage-related cleanups
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 11:49:05 PDT 2019
Author: nico
Date: Tue Jun 4 11:49:05 2019
New Revision: 362540
URL: http://llvm.org/viewvc/llvm-project?rev=362540&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
llvm/trunk/test/Demangle/invalid-manglings.test
llvm/trunk/test/Demangle/ms-basic.test
llvm/trunk/test/Demangle/ms-templates.test
Modified: llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp?rev=362540&r1=362539&r2=362540&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp Tue Jun 4 11:49:05 2019
@@ -2093,7 +2093,7 @@ ArrayTypeNode *Demangler::demangleArrayT
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
return NA;
}
- Error = true;
- return nullptr;
+ DEMANGLE_UNREACHABLE;
}
NodeArrayNode *
@@ -2167,7 +2166,7 @@ Demangler::demangleTemplateParameterList
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
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() {
Modified: llvm/trunk/test/Demangle/invalid-manglings.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/invalid-manglings.test?rev=362540&r1=362539&r2=362540&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/invalid-manglings.test (original)
+++ llvm/trunk/test/Demangle/invalid-manglings.test Tue Jun 4 11:49:05 2019
@@ -100,6 +100,16 @@
; CHECK-NEXT: ??__E?Foo@@YAXXZ
; CHECK-NEXT: error: Invalid mangled name
+?foo@@YAH0 at Z
+; CHECK-EMPTY:
+; CHECK-NEXT: ?foo@@YAH0 at Z
+; CHECK-NEXT: error: Invalid mangled name
+
+?foo@@YAHH
+; CHECK-EMPTY:
+; CHECK-NEXT: ?foo@@YAHH
+; CHECK-NEXT: error: Invalid mangled name
+
??8 at 8
; CHECK-EMPTY:
; CHECK-NEXT: ??8 at 8
Modified: llvm/trunk/test/Demangle/ms-basic.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-basic.test?rev=362540&r1=362539&r2=362540&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-basic.test (original)
+++ llvm/trunk/test/Demangle/ms-basic.test Tue Jun 4 11:49:05 2019
@@ -38,6 +38,10 @@
?x@@YAXMH at Z
; CHECK: void __cdecl x(float, int)
+?x@@YAXMHZZ
+; FIXME: This should be `(float, int, ...)`
+; CHECK: void __cdecl x(float, int)
+
?x@@3P6AHMNH at ZEA
; CHECK: int (__cdecl *x)(float, double, int)
Modified: llvm/trunk/test/Demangle/ms-templates.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-templates.test?rev=362540&r1=362539&r2=362540&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-templates.test (original)
+++ llvm/trunk/test/Demangle/ms-templates.test Tue Jun 4 11:49:05 2019
@@ -4,6 +4,8 @@
; CHECK-NOT: Invalid mangled name
+?f@@3V?$C at H@@A
+; CHECK: class C<int> f
??0?$Class at VTypename@@@@QAE at XZ
; CHECK: __thiscall Class<class Typename>::Class<class Typename>(void)
More information about the llvm-commits
mailing list