[MS Demangler] Properly print all thunk types.
authorZachary Turner <zturner@google.com>
Fri, 17 Aug 2018 21:32:07 +0000 (21:32 +0000)
committerZachary Turner <zturner@google.com>
Fri, 17 Aug 2018 21:32:07 +0000 (21:32 +0000)
We were only printing the vtordisp thunk before as the previous
patch was more aimed at getting special operators working, one
of which was a thunk.  This patch gets all thunk types to print
properly, and adds a test for each one.

llvm-svn: 340088

llvm/lib/Demangle/MicrosoftDemangle.cpp
llvm/test/Demangle/ms-operators.test
llvm/test/Demangle/ms-thunks.test [new file with mode: 0644]

index 172ba0b..a307914 100644 (file)
@@ -945,7 +945,6 @@ static void outputSpecialOperator(OutputStream &OS, const Name *OuterName,
     break;
   }
   case OperatorTy::Vcall: {
-    // [thunk]: __cdecl Base::`vcall'{8, {flat}}' }'
     const VirtualMemberPtrThunk &Thunk =
         static_cast<const VirtualMemberPtrThunk &>(Oper);
     OS << "[thunk]: ";
@@ -1194,9 +1193,17 @@ void FunctionType::outputPost(OutputStream &OS, NameResolver &Resolver) {
   if (FunctionClass & NoPrototype)
     return;
 
-  if (FunctionClass & VirtualThisAdjust) {
-    OS << "`vtordisp{" << ThisAdjust->VtordispOffset << ", "
-       << ThisAdjust->StaticOffset << "}'";
+  if (FunctionClass & StaticThisAdjust) {
+    OS << "`adjustor{" << ThisAdjust->StaticOffset << "}'";
+  } else if (FunctionClass & VirtualThisAdjust) {
+    if (FunctionClass & VirtualThisAdjustEx) {
+      OS << "`vtordispex{" << ThisAdjust->VBPtrOffset << ", "
+         << ThisAdjust->VBOffsetOffset << ", " << ThisAdjust->VtordispOffset
+         << ", " << ThisAdjust->StaticOffset << "}'";
+    } else {
+      OS << "`vtordisp{" << ThisAdjust->VtordispOffset << ", "
+         << ThisAdjust->StaticOffset << "}'";
+    }
   }
 
   OS << "(";
index 54da11c..de5c189 100644 (file)
 ??_EBase@@UEAAPEAXI@Z
 ; CHECK: virtual void * __cdecl Base::`vector deleting dtor'(unsigned int)
 
-??_EDerived@@$4PPPPPPPM@A@EAAPEAXI@Z
-; CHECK: [thunk]: virtual void * __cdecl Derived::`vector deleting dtor'`vtordisp{-4, 0}'(unsigned int)
-
 ??_F?$SomeTemplate@H@@QAEXXZ
 ; CHECK: void __thiscall SomeTemplate<int>::`default ctor closure'(void)
 
diff --git a/llvm/test/Demangle/ms-thunks.test b/llvm/test/Demangle/ms-thunks.test
new file mode 100644 (file)
index 0000000..668daa8
--- /dev/null
@@ -0,0 +1,15 @@
+; RUN: llvm-undname < %s | FileCheck %s
+
+; CHECK-NOT: Invalid mangled name
+
+?f@C@@WBA@EAAHXZ
+; CHECK: [thunk]: virtual int __cdecl C::f`adjustor{16}'(void)
+
+??_EDerived@@$4PPPPPPPM@A@EAAPEAXI@Z
+; CHECK: [thunk]: virtual void * __cdecl Derived::`vector deleting dtor'`vtordisp{-4, 0}'(unsigned int)
+
+?f@A@simple@@$R477PPPPPPPM@7AEXXZ
+; CHECK: [thunk]: virtual void __thiscall simple::A::f`vtordispex{8, 8, -4, 8}'(void)
+
+??_9Base@@$B7AA
+; CHECK: [thunk]: __cdecl Base::`vcall'{8, {flat}}