@@ -34,21 +34,18 @@ Ref<Symbol> RTTI::GetRealSymbol(BinaryView *view, uint64_t relocAddr, uint64_t s
3434}
3535
3636
37- std::optional<std::string> RTTI::DemangleNameMS (BinaryView* view, bool allowMangled, const std::string &mangledName)
37+ std::optional<std::string> RTTI::DemangleNameMS (
38+ BinaryView* view, bool allowMangled, const std::string &mangledName, bool simplifyTemplates)
3839{
39- QualifiedName demangledName = {};
40- Ref<Type> outType = {};
41- if (!DemangleMS (view->GetDefaultArchitecture (), mangledName, outType, demangledName, view))
40+ auto result = DemangleMS (view->GetDefaultPlatform (), mangledName, simplifyTemplates);
41+ if (!result)
4242 return DemangleNameLLVM (allowMangled, mangledName);
43- return NormalizeRTTIClassName (demangledName .GetString ());
43+ return NormalizeRTTIClassName (result-> name .GetString ());
4444}
4545
4646
4747std::optional<std::string> RTTI::DemangleNameGNU3 (BinaryView* view, bool allowMangled, const std::string &mangledName)
4848{
49- QualifiedName demangledName = {};
50- Ref<Type> outType = {};
51-
5249 std::string adjustedMangledName = mangledName;
5350 // For some reason some of the names that start with ZN are not prefixed by `_`.
5451 if (adjustedMangledName.rfind (" ZN" , 0 ) == 0 )
@@ -62,7 +59,8 @@ std::optional<std::string> RTTI::DemangleNameGNU3(BinaryView* view, bool allowMa
6259 if (adjustedMangledName.rfind (" _Z" , 0 ) != 0 )
6360 adjustedMangledName = " _Z" + adjustedMangledName;
6461
65- if (!DemangleGNU3 (view->GetDefaultArchitecture (), adjustedMangledName, outType, demangledName, true ))
62+ auto result = DemangleGNU3 (view->GetDefaultPlatform (), adjustedMangledName, true );
63+ if (!result)
6664 return allowMangled ? std::optional (mangledName) : std::nullopt ;
6765
6866 // Because we might have a generic name such as "PackageListGui::PackageListGui" returned, we must attempt to
@@ -71,10 +69,10 @@ std::optional<std::string> RTTI::DemangleNameGNU3(BinaryView* view, bool allowMa
7169 // MANGLED: ZN14PackageListGuiC1EON10Filesystem4PathENS_14UnderSubheaderEbE3$_1
7270 // GENERIC DEMANGLED: PackageListGui::PackageListGui
7371 // UPDATED DEMANGLED: PackageListGui::PackageListGui(Filesystem::Path&&, PackageListGui::UnderSubheader, bool)
74- if (outType && outType ->IsFunction ())
75- demangledName .push_back (outType ->GetStringAfterName (view->GetDefaultPlatform ()));
72+ if (result-> type && result-> type ->IsFunction ())
73+ result-> name .push_back (result-> type ->GetStringAfterName (view->GetDefaultPlatform ()));
7674
77- return demangledName .GetString ();
75+ return result-> name .GetString ();
7876}
7977
8078
@@ -100,11 +98,10 @@ std::optional<std::string> RTTI::DemangleNameItanium(BinaryView* view, bool allo
10098
10199std::optional<std::string> RTTI::DemangleNameLLVM (bool allowMangled, const std::string &mangledName)
102100{
103- QualifiedName demangledName = {};
104- Ref<Type> outType = {};
105- if (!DemangleLLVM (mangledName, demangledName, true ))
101+ auto result = DemangleLLVM (mangledName, true );
102+ if (!result)
106103 return allowMangled ? std::optional (mangledName) : std::nullopt ;
107- return NormalizeRTTIClassName (demangledName .GetString ());
104+ return NormalizeRTTIClassName (result-> name .GetString ());
108105}
109106
110107
0 commit comments