[llvm] r346791 - [MS Demangler] Print public:, protected:, private: if set in FunctionClass or a variable's StorageClass.

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 13 12:18:27 PST 2018


Author: nico
Date: Tue Nov 13 12:18:26 2018
New Revision: 346791

URL: http://llvm.org/viewvc/llvm-project?rev=346791&view=rev
Log:
[MS Demangler] Print public:, protected:, private: if set in FunctionClass or a variable's StorageClass.

undname prints them, and the information is in the decorated name, so we probably shouldn't lose it when undecorating.

I spot-checked a few of the funnier-looking outputs, and undname has the same output.

Differential Revision: https://reviews.llvm.org/D54396

Modified:
    llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp
    llvm/trunk/test/Demangle/ms-cxx11.test
    llvm/trunk/test/Demangle/ms-cxx14.test
    llvm/trunk/test/Demangle/ms-nested-scopes.test
    llvm/trunk/test/Demangle/ms-operators.test
    llvm/trunk/test/Demangle/ms-template-callback.test
    llvm/trunk/test/Demangle/ms-templates-memptrs.test
    llvm/trunk/test/Demangle/ms-templates.test
    llvm/trunk/test/Demangle/ms-thunks.test

Modified: llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp?rev=346791&r1=346790&r2=346791&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp Tue Nov 13 12:18:26 2018
@@ -368,16 +368,23 @@ void LiteralOperatorIdentifierNode::outp
 
 void FunctionSignatureNode::outputPre(OutputStream &OS,
                                       OutputFlags Flags) const {
+  if (FunctionClass & FC_Public)
+    OS << "public: ";
+  if (FunctionClass & FC_Protected)
+    OS << "protected: ";
+  if (FunctionClass & FC_Private)
+    OS << "private: ";
+
   if (!(FunctionClass & FC_Global)) {
     if (FunctionClass & FC_Static)
       OS << "static ";
   }
-  if (FunctionClass & FC_ExternC)
-    OS << "extern \"C\" ";
-
   if (FunctionClass & FC_Virtual)
     OS << "virtual ";
 
+  if (FunctionClass & FC_ExternC)
+    OS << "extern \"C\" ";
+
   if (ReturnType) {
     ReturnType->outputPre(OS, Flags);
     OS << " ";
@@ -554,9 +561,13 @@ void FunctionSymbolNode::output(OutputSt
 void VariableSymbolNode::output(OutputStream &OS, OutputFlags Flags) const {
   switch (SC) {
   case StorageClass::PrivateStatic:
+    OS << "private: static ";
+    break;
   case StorageClass::PublicStatic:
+    OS << "public: static ";
+    break;
   case StorageClass::ProtectedStatic:
-    OS << "static ";
+    OS << "protected: static ";
     break;
   default:
     break;

Modified: llvm/trunk/test/Demangle/ms-cxx11.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-cxx11.test?rev=346791&r1=346790&r2=346791&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-cxx11.test (original)
+++ llvm/trunk/test/Demangle/ms-cxx11.test Tue Nov 13 12:18:26 2018
@@ -111,10 +111,10 @@
 ; CHECK: int __cdecl PR18204::f<union PR18204::<unnamed-type-$S1>>(union PR18204::<unnamed-type-$S1> *)
 
 ??R<lambda_0>@?0??PR26105@@YAHXZ at QBE@H at Z
-; CHECK: __thiscall `int __cdecl PR26105(void)'::`1'::<lambda_0>::operator()(int) const
+; CHECK: public: __thiscall `int __cdecl PR26105(void)'::`1'::<lambda_0>::operator()(int) const
 
 ??R<lambda_1>@?0???R<lambda_0>@?0??PR26105@@YAHXZ at QBE@H at Z@QBE at H@Z
-; CHECK: __thiscall `__thiscall `int __cdecl PR26105(void)'::`1'::<lambda_0>::operator()(int) const'::`1'::<lambda_1>::operator()(int) const
+; CHECK: public: __thiscall `public: __thiscall `int __cdecl PR26105(void)'::`1'::<lambda_0>::operator()(int) const'::`1'::<lambda_1>::operator()(int) const
 
 ?unaligned_foo1@@YAPFAHXZ
 ; CHECK: int __unaligned * __cdecl unaligned_foo1(void)
@@ -144,7 +144,7 @@
 ; CHECK: __thiscall PR31197::A::x::<lambda_1>::operator()(void) const
 
 ?white@?1???R<lambda_1>@x at A@PR31197@@QBE at XZ@4HA
-; CHECK: int `__thiscall PR31197::A::x::<lambda_1>::operator()(void) const'::`2'::white
+; CHECK: int `public: __thiscall PR31197::A::x::<lambda_1>::operator()(void) const'::`2'::white
 
 ?f@@YAXW4<unnamed-enum-enumerator>@@@Z
 ; CHECK: void __cdecl f(enum <unnamed-enum-enumerator>)

Modified: llvm/trunk/test/Demangle/ms-cxx14.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-cxx14.test?rev=346791&r1=346790&r2=346791&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-cxx14.test (original)
+++ llvm/trunk/test/Demangle/ms-cxx14.test Tue Nov 13 12:18:26 2018
@@ -16,10 +16,10 @@
 ; CHECK: <auto> __thiscall <lambda_0>::operator()(void) const
 
 ?ValueFromLambdaWithLocalType@@3ULocalType@?1???R<lambda_0>@@QBE?A?<auto>@@XZ at A
-; CHECK: struct `<auto> __thiscall <lambda_0>::operator()(void) const'::`2'::LocalType ValueFromLambdaWithLocalType
+; CHECK: struct `public: <auto> __thiscall <lambda_0>::operator()(void) const'::`2'::LocalType ValueFromLambdaWithLocalType
 
 ?ValueFromTemplateFuncionWithLocalLambda@@3ULocalType@?2???R<lambda_1>@?0???$TemplateFuncionWithLocalLambda at H@@YA?A?<auto>@@H at Z@QBE?A?3 at XZ@A
-; CHECK: struct `<auto> __thiscall `<auto> __cdecl TemplateFuncionWithLocalLambda<int>(int)'::`1'::<lambda_1>::operator()(void) const'::`3'::LocalType ValueFromTemplateFuncionWithLocalLambda
+; CHECK: struct `public: <auto> __thiscall `<auto> __cdecl TemplateFuncionWithLocalLambda<int>(int)'::`1'::<lambda_1>::operator()(void) const'::`3'::LocalType ValueFromTemplateFuncionWithLocalLambda
 
 ??$TemplateFuncionWithLocalLambda at H@@YA?A?<auto>@@H at Z
 ; CHECK: <auto> __cdecl TemplateFuncionWithLocalLambda<int>(int)

Modified: llvm/trunk/test/Demangle/ms-nested-scopes.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-nested-scopes.test?rev=346791&r1=346790&r2=346791&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-nested-scopes.test (original)
+++ llvm/trunk/test/Demangle/ms-nested-scopes.test Tue Nov 13 12:18:26 2018
@@ -81,10 +81,10 @@
 ; CHECK: int `int __cdecl M(void)'::`2'::M
 
 ?L@?2??M at 0?2??0 at YAHXZ@QEAAHXZ at 4HA
-; CHECK: int `int __cdecl `int __cdecl L(void)'::`3'::L::M(void)'::`3'::L
+; CHECK: int `public: int __cdecl `int __cdecl L(void)'::`3'::L::M(void)'::`3'::L
 
 ?M@?2??0L@?2??1 at YAHXZ@QEAAHXZ at 4HA
-; CHECK: int `int __cdecl `int __cdecl L(void)'::`3'::L::M(void)'::`3'::M
+; CHECK: int `public: int __cdecl `int __cdecl L(void)'::`3'::L::M(void)'::`3'::M
 
 ; Function local scopes of template functions
 ?M@?1???$L at H@@YAHXZ at 4HA
@@ -95,16 +95,16 @@
 ; CHECK: int __cdecl NS::NS<int>::SN(void)
 
 ?NS@?1??SN@?$NS at H@0 at QEAAHXZ@4HA
-; CHECK: int `int __cdecl NS::NS<int>::SN(void)'::`2'::NS
+; CHECK: int `public: int __cdecl NS::NS<int>::SN(void)'::`2'::NS
 
 ?SN@?1??0?$NS at H@NS@@QEAAHXZ at 4HA
-; CHECK: int `int __cdecl NS::NS<int>::SN(void)'::`2'::SN
+; CHECK: int `public: int __cdecl NS::NS<int>::SN(void)'::`2'::SN
 
 ?NS@?1??SN@?$NS at H@10 at QEAAHXZ@4HA
-; CHECK: int `int __cdecl NS::SN::NS<int>::SN(void)'::`2'::NS
+; CHECK: int `public: int __cdecl NS::SN::NS<int>::SN(void)'::`2'::NS
 
 ?SN@?1??0?$NS at H@0NS@@QEAAHXZ at 4HA
-; CHECK: int `int __cdecl NS::SN::NS<int>::SN(void)'::`2'::SN
+; CHECK: int `public: int __cdecl NS::SN::NS<int>::SN(void)'::`2'::SN
 
 ; Make sure instantiated templates participate in back-referencing.
 ; In the next 3 examples there should be 3 back-references:
@@ -137,10 +137,10 @@
 ; } } } } }
 
 ?C@?1??B@?$C at H@0101A@@QEAAHXZ at 4U201013@A
-; CHECK: struct A::B::C::B::C::C<int> `int __cdecl A::B::C::B::C::C<int>::B(void)'::`2'::C
+; CHECK: struct A::B::C::B::C::C<int> `public: int __cdecl A::B::C::B::C::C<int>::B(void)'::`2'::C
 
 ?B@?1??0?$C at H@C at 020A@@QEAAHXZ at 4HA
-; CHECK: int `int __cdecl A::B::C::B::C::C<int>::B(void)'::`2'::B
+; CHECK: int `public: int __cdecl A::B::C::B::C::C<int>::B(void)'::`2'::B
 
 ?A@?1??B@?$C at H@C at 1310@QEAAHXZ at 4HA
-; CHECK: int `int __cdecl A::B::C::B::C::C<int>::B(void)'::`2'::A
+; CHECK: int `public: int __cdecl A::B::C::B::C::C<int>::B(void)'::`2'::A

Modified: llvm/trunk/test/Demangle/ms-operators.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-operators.test?rev=346791&r1=346790&r2=346791&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-operators.test (original)
+++ llvm/trunk/test/Demangle/ms-operators.test Tue Nov 13 12:18:26 2018
@@ -162,7 +162,7 @@
 ; CHECK: virtual void * __cdecl Base::`vector deleting dtor'(unsigned int)
 
 ??_EBase@@G3AEPAXI at Z
-; CHECK: [thunk]: void * __thiscall Base::`vector deleting dtor'`adjustor{4}'(unsigned int)
+; CHECK: [thunk]: private: void * __thiscall Base::`vector deleting dtor'`adjustor{4}'(unsigned int)
 
 ??_F?$SomeTemplate at H@@QAEXXZ
 ; CHECK: void __thiscall SomeTemplate<int>::`default ctor closure'(void)
@@ -228,7 +228,7 @@
 ; CHECK: void __cdecl `dynamic atexit destructor for 'Foo''(void)
 
 ??__F_decisionToDFA at XPathLexer@@0V?$vector at VDFA@dfa at antlr4@@V?$allocator at VDFA@dfa at antlr4@@@std@@@std@@A at YAXXZ
-; CHECK: void __cdecl `dynamic atexit destructor for `static class std::vector<class antlr4::dfa::DFA, class std::allocator<class antlr4::dfa::DFA>> XPathLexer::_decisionToDFA''(void)
+; CHECK: void __cdecl `dynamic atexit destructor for `private: static class std::vector<class antlr4::dfa::DFA, class std::allocator<class antlr4::dfa::DFA>> XPathLexer::_decisionToDFA''(void)
 
 ??__K_deg@@YAHO at Z
 ; CHECK: int __cdecl operator ""_deg(long double)

Modified: llvm/trunk/test/Demangle/ms-template-callback.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-template-callback.test?rev=346791&r1=346790&r2=346791&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-template-callback.test (original)
+++ llvm/trunk/test/Demangle/ms-template-callback.test Tue Nov 13 12:18:26 2018
@@ -47,7 +47,7 @@
 ; CHECK: void __cdecl WrapFnRef<&void __cdecl VoidFn(void)>(void)
 
 ??$WrapFnPtr@$1?VoidStaticMethod at Thing@@SAXXZ@@YAXXZ
-; CHECK: void __cdecl WrapFnPtr<&static void __cdecl Thing::VoidStaticMethod(void)>(void)
+; CHECK: void __cdecl WrapFnPtr<&public: static void __cdecl Thing::VoidStaticMethod(void)>(void)
 
 ??$WrapFnRef@$1?VoidStaticMethod at Thing@@SAXXZ@@YAXXZ
-; CHECK: void __cdecl WrapFnRef<&static void __cdecl Thing::VoidStaticMethod(void)>(void)
+; CHECK: void __cdecl WrapFnRef<&public: static void __cdecl Thing::VoidStaticMethod(void)>(void)

Modified: llvm/trunk/test/Demangle/ms-templates-memptrs.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-templates-memptrs.test?rev=346791&r1=346790&r2=346791&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-templates-memptrs.test (original)
+++ llvm/trunk/test/Demangle/ms-templates-memptrs.test Tue Nov 13 12:18:26 2018
@@ -12,7 +12,7 @@
 ; CHECK: void __cdecl CallMethod<struct M, {[thunk]: __thiscall M::`vcall'{0, {flat}}, 0}>(struct M &)
 
 ??$CallMethod at UM@@$H?f at 1@QAEXXZA@@@YAXAAUM@@@Z
-; CHECK: void __cdecl CallMethod<struct M, {void __thiscall M::f(void), 0}>(struct M &)
+; CHECK: void __cdecl CallMethod<struct M, {public: void __thiscall M::f(void), 0}>(struct M &)
 
 ??$CallMethod at UO@@$H??_91@$BA at AE3@@YAXAAUO@@@Z
 ; CHECK: void __cdecl CallMethod<struct O, {[thunk]: __thiscall O::`vcall'{0, {flat}}, 4}>(struct O &)
@@ -24,7 +24,7 @@
 ; CHECK: void __cdecl CallMethod<struct S, &[thunk]: __thiscall S::`vcall'{0, {flat}}>(struct S &)
 
 ??$CallMethod at US@@$1?f at 1@QAEXXZ@@YAXAAUS@@@Z
-; CHECK: void __cdecl CallMethod<struct S, &void __thiscall S::f(void)>(struct S &)
+; CHECK: void __cdecl CallMethod<struct S, &public: void __thiscall S::f(void)>(struct S &)
 
 ??$CallMethod at UU@@$0A@@@YAXAAUU@@@Z
 ; CHECK: void __cdecl CallMethod<struct U, 0>(struct U &)
@@ -33,7 +33,7 @@
 ; CHECK: void __cdecl CallMethod<struct U, {[thunk]: __thiscall U::`vcall'{0, {flat}}, 0, 0, 0}>(struct U &)
 
 ??$CallMethod at UU@@$J?f at 1@QAEXXZA at A@A@@@YAXAAUU@@@Z
-; CHECK: void __cdecl CallMethod<struct U, {void __thiscall U::f(void), 0, 0, 0}>(struct U &)
+; CHECK: void __cdecl CallMethod<struct U, {public: void __thiscall U::f(void), 0, 0, 0}>(struct U &)
 
 ??$CallMethod at UV@@$0A@@@YAXAAUV@@@Z
 ; CHECK: void __cdecl CallMethod<struct V, 0>(struct V &)
@@ -42,7 +42,7 @@
 ; CHECK: void __cdecl CallMethod<struct V, {[thunk]: __thiscall V::`vcall'{0, {flat}}, 0, 0}>(struct V &)
 
 ??$CallMethod at UV@@$I?f at 1@QAEXXZA at A@@@YAXAAUV@@@Z
-; CHECK: void __cdecl CallMethod<struct V, {void __thiscall V::f(void), 0, 0}>(struct V &)
+; CHECK: void __cdecl CallMethod<struct V, {public: void __thiscall V::f(void), 0, 0}>(struct V &)
 
 ??$ReadField at UA@@$0?0@@YAHAAUA@@@Z
 ; CHECK: int __cdecl ReadField<struct A, -1>(struct A &)

Modified: llvm/trunk/test/Demangle/ms-templates.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-templates.test?rev=346791&r1=346790&r2=346791&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-templates.test (original)
+++ llvm/trunk/test/Demangle/ms-templates.test Tue Nov 13 12:18:26 2018
@@ -195,7 +195,7 @@
 ; CHECK: void __thiscall UUIDType4<&struct __s_GUID const _GUID_12345678_1234_1234_1234_1234567890ab>::bar(void)
 
 ??$f at US@@$1?g at 1@QEAAXXZ@@YAXXZ
-; CHECK: void __cdecl f<struct S, &void __cdecl S::g(void)>(void)
+; CHECK: void __cdecl f<struct S, &public: 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
+; CHECK: __cdecl Foo<int>::Foo<int><double>(double)

Modified: llvm/trunk/test/Demangle/ms-thunks.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-thunks.test?rev=346791&r1=346790&r2=346791&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-thunks.test (original)
+++ llvm/trunk/test/Demangle/ms-thunks.test Tue Nov 13 12:18:26 2018
@@ -3,13 +3,13 @@
 ; CHECK-NOT: Invalid mangled name
 
 ?f at C@@WBA at EAAHXZ
-; CHECK: [thunk]: virtual int __cdecl C::f`adjustor{16}'(void)
+; CHECK: [thunk]: public: virtual int __cdecl C::f`adjustor{16}'(void)
 
 ??_EDerived@@$4PPPPPPPM at A@EAAPEAXI at Z
-; CHECK: [thunk]: virtual void * __cdecl Derived::`vector deleting dtor'`vtordisp{-4, 0}'(unsigned int)
+; CHECK: [thunk]: public: virtual void * __cdecl Derived::`vector deleting dtor'`vtordisp{-4, 0}'(unsigned int)
 
 ?f at A@simple@@$R477PPPPPPPM at 7AEXXZ
-; CHECK: [thunk]: virtual void __thiscall simple::A::f`vtordispex{8, 8, -4, 8}'(void)
+; CHECK: [thunk]: public: virtual void __thiscall simple::A::f`vtordispex{8, 8, -4, 8}'(void)
 
 ??_9Base@@$B7AA
 ; CHECK: [thunk]: __cdecl Base::`vcall'{8, {flat}}




More information about the llvm-commits mailing list