[llvm] r340356 - [MS Demangler] Print template constructor args.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 21 15:52:52 PDT 2018
Author: zturner
Date: Tue Aug 21 15:52:52 2018
New Revision: 340356
URL: http://llvm.org/viewvc/llvm-project?rev=340356&view=rev
Log:
[MS Demangler] Print template constructor args.
Previously if you had something like this:
template<typename T>
struct Foo {
template<typename U>
Foo(U);
};
Foo F(3.7);
this would mangle as ??$?0N@?$Foo at H@@QEAA at N@Z
and this would be demangled as:
undname: __cdecl Foo<int>::Foo<int><double>(double)
llvm-undname: __cdecl Foo<int>::Foo<int>(double)
Note the lack of the constructor template parameter in our
demangling.
This patch makes it so we print the constructor argument list.
Modified:
llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
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=340356&r1=340355&r2=340356&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp Tue Aug 21 15:52:52 2018
@@ -969,7 +969,20 @@ static void outputName(OutputStream &OS,
OS << "~";
LLVM_FALLTHROUGH;
case OperatorTy::Ctor:
+ // Output the class name with template arguments a second time.
outputNameComponent(OS, *Previous);
+
+ // Structors don't have a name, so outputting the name here actually is a
+ // no-op. But for template constructors, it needs to output the template
+ // argument list. e.g.
+ //
+ // template<typename T>
+ // struct Foo {
+ // template<typename U>
+ // Foo(U);
+ // };
+ // should demangle as -- for example -- Foo<int><double>(double);
+ outputNameComponent(OS, *TheName);
break;
case OperatorTy::Conversion:
OS << "operator";
Modified: llvm/trunk/test/Demangle/ms-templates.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-templates.test?rev=340356&r1=340355&r2=340356&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-templates.test (original)
+++ llvm/trunk/test/Demangle/ms-templates.test Tue Aug 21 15:52:52 2018
@@ -196,3 +196,6 @@
??$f at US@@$1?g at 1@QEAAXXZ@@YAXXZ
; CHECK: void __cdecl f<struct S, &void __cdecl S::g(void)>(void)
+
+??$?0N@?$Foo at H@@QEAA at N@Z
+; CHECK: __cdecl Foo<int>::Foo<int><double>(double)
\ No newline at end of file
More information about the llvm-commits
mailing list