[Lldb-commits] [PATCH] D103107: [lldb] Remove cache in get_demangled_name_without_arguments

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 26 09:28:12 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd28bc54ff44a: [lldb] Remove cache in get_demangled_name_without_arguments (authored by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103107/new/

https://reviews.llvm.org/D103107

Files:
  lldb/source/Core/Mangled.cpp


Index: lldb/source/Core/Mangled.cpp
===================================================================
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -35,26 +35,8 @@
   return Mangled::GetManglingScheme(s) != Mangled::eManglingSchemeNone;
 }
 
-static ConstString 
-get_demangled_name_without_arguments(ConstString mangled,
-                                     ConstString demangled) {
-  // This pair is <mangled name, demangled name without function arguments>
-  static std::pair<ConstString, ConstString>
-      g_most_recent_mangled_to_name_sans_args;
-
-  // Need to have the mangled & demangled names we're currently examining as
-  // statics so we can return a const ref to them at the end of the func if we
-  // don't have anything better.
-  static ConstString g_last_mangled;
-  static ConstString g_last_demangled;
-
-  if (mangled && g_most_recent_mangled_to_name_sans_args.first == mangled) {
-    return g_most_recent_mangled_to_name_sans_args.second;
-  }
-
-  g_last_demangled = demangled;
-  g_last_mangled = mangled;
-
+static ConstString GetDemangledNameWithoutArguments(ConstString mangled,
+                                                    ConstString demangled) {
   const char *mangled_name_cstr = mangled.GetCString();
 
   if (demangled && mangled_name_cstr && mangled_name_cstr[0]) {
@@ -73,17 +55,13 @@
         if (!cxx_method.GetContext().empty())
           shortname = cxx_method.GetContext().str() + "::";
         shortname += cxx_method.GetBasename().str();
-        ConstString result(shortname.c_str());
-        g_most_recent_mangled_to_name_sans_args.first = mangled;
-        g_most_recent_mangled_to_name_sans_args.second = result;
-        return g_most_recent_mangled_to_name_sans_args.second;
+        return ConstString(shortname);
       }
     }
   }
-
   if (demangled)
-    return g_last_demangled;
-  return g_last_mangled;
+    return demangled;
+  return mangled;
 }
 
 #pragma mark Mangled
@@ -347,7 +325,7 @@
   ConstString demangled = GetDemangledName();
 
   if (preference == ePreferDemangledWithoutArguments) {
-    return get_demangled_name_without_arguments(m_mangled, demangled);
+    return GetDemangledNameWithoutArguments(m_mangled, demangled);
   }
   if (preference == ePreferDemangled) {
     // Call the accessor to make sure we get a demangled name in case it hasn't


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103107.347997.patch
Type: text/x-patch
Size: 2365 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210526/6651dcf2/attachment.bin>


More information about the lldb-commits mailing list