Skip to content

Commit ee09170

Browse files
author
Zachary Turner
committed
[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@H@@qeaa@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. llvm-svn: 340356
1 parent 986f03c commit ee09170

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

llvm/lib/Demangle/MicrosoftDemangle.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,20 @@ static void outputName(OutputStream &OS, const Name *TheName, const Type *Ty) {
969969
OS << "~";
970970
LLVM_FALLTHROUGH;
971971
case OperatorTy::Ctor:
972+
// Output the class name with template arguments a second time.
972973
outputNameComponent(OS, *Previous);
974+
975+
// Structors don't have a name, so outputting the name here actually is a
976+
// no-op. But for template constructors, it needs to output the template
977+
// argument list. e.g.
978+
//
979+
// template<typename T>
980+
// struct Foo {
981+
// template<typename U>
982+
// Foo(U);
983+
// };
984+
// should demangle as -- for example -- Foo<int><double>(double);
985+
outputNameComponent(OS, *TheName);
973986
break;
974987
case OperatorTy::Conversion:
975988
OS << "operator";

llvm/test/Demangle/ms-templates.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,6 @@
196196

197197
??$f@US@@$1?g@1@QEAAXXZ@@YAXXZ
198198
; CHECK: void __cdecl f<struct S, &void __cdecl S::g(void)>(void)
199+
200+
??$?0N@?$Foo@H@@QEAA@N@Z
201+
; CHECK: __cdecl Foo<int>::Foo<int><double>(double)

0 commit comments

Comments
 (0)