[llvm] r362541 - llvm-undname: Correctly demangle vararg parameters
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 12:10:08 PDT 2019
Author: nico
Date: Tue Jun 4 12:10:08 2019
New Revision: 362541
URL: http://llvm.org/viewvc/llvm-project?rev=362541&view=rev
Log:
llvm-undname: Correctly demangle vararg parameters
FunctionSignatureNode already had an IsVariadic field,
but it wasn't used anywhere yet. Set it and use it.
Modified:
llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h
llvm/trunk/include/llvm/Demangle/MicrosoftDemangleNodes.h
llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp
llvm/trunk/test/Demangle/ms-basic.test
Modified: llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h?rev=362541&r1=362540&r2=362541&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h (original)
+++ llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h Tue Jun 4 12:10:08 2019
@@ -177,8 +177,9 @@ private:
ArrayTypeNode *demangleArrayType(StringView &MangledName);
+ NodeArrayNode *demangleFunctionParameterList(StringView &MangledName,
+ bool &IsVariadic);
NodeArrayNode *demangleTemplateParameterList(StringView &MangledName);
- NodeArrayNode *demangleFunctionParameterList(StringView &MangledName);
std::pair<uint64_t, bool> demangleNumber(StringView &MangledName);
uint64_t demangleUnsigned(StringView &MangledName);
Modified: llvm/trunk/include/llvm/Demangle/MicrosoftDemangleNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Demangle/MicrosoftDemangleNodes.h?rev=362541&r1=362540&r2=362541&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Demangle/MicrosoftDemangleNodes.h (original)
+++ llvm/trunk/include/llvm/Demangle/MicrosoftDemangleNodes.h Tue Jun 4 12:10:08 2019
@@ -344,7 +344,7 @@ struct FunctionSignatureNode : public Ty
// Function parameters
NodeArrayNode *Params = nullptr;
- // True if the function type is noexcept
+ // True if the function type is noexcept.
bool IsNoexcept = false;
};
Modified: llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp?rev=362541&r1=362540&r2=362541&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp Tue Jun 4 12:10:08 2019
@@ -1826,7 +1826,7 @@ FunctionSignatureNode *Demangler::demang
if (!IsStructor)
FTy->ReturnType = demangleType(MangledName, QualifierMangleMode::Result);
- FTy->Params = demangleFunctionParameterList(MangledName);
+ FTy->Params = demangleFunctionParameterList(MangledName, FTy->IsVariadic);
FTy->IsNoexcept = demangleThrowSpecification(MangledName);
@@ -2094,8 +2094,8 @@ ArrayTypeNode *Demangler::demangleArrayT
}
// Reads a function's parameters.
-NodeArrayNode *
-Demangler::demangleFunctionParameterList(StringView &MangledName) {
+NodeArrayNode *Demangler::demangleFunctionParameterList(StringView &MangledName,
+ bool &IsVariadic) {
// Empty parameter list.
if (MangledName.consumeFront('X'))
return nullptr;
@@ -2152,8 +2152,7 @@ Demangler::demangleFunctionParameterList
return NA;
if (MangledName.consumeFront('Z')) {
- // This is a variadic parameter list. We probably need a variadic node to
- // append to the end.
+ IsVariadic = true;
return NA;
}
Modified: llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp?rev=362541&r1=362540&r2=362541&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp Tue Jun 4 12:10:08 2019
@@ -414,6 +414,12 @@ void FunctionSignatureNode::outputPost(O
Params->output(OS, Flags);
else
OS << "void";
+
+ if (IsVariadic) {
+ if (OS.back() != '(')
+ OS << ", ";
+ OS << "...";
+ }
OS << ")";
}
Modified: llvm/trunk/test/Demangle/ms-basic.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-basic.test?rev=362541&r1=362540&r2=362541&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-basic.test (original)
+++ llvm/trunk/test/Demangle/ms-basic.test Tue Jun 4 12:10:08 2019
@@ -39,8 +39,10 @@
; CHECK: void __cdecl x(float, int)
?x@@YAXMHZZ
-; FIXME: This should be `(float, int, ...)`
-; CHECK: void __cdecl x(float, int)
+; CHECK: void __cdecl x(float, int, ...)
+
+?x@@YAXZZ
+; CHECK: void __cdecl x(...)
?x@@3P6AHMNH at ZEA
; CHECK: int (__cdecl *x)(float, double, int)
More information about the llvm-commits
mailing list