[Lldb-commits] [PATCH] D105215: [lldb] Remove CPlusPlusLanguage from Mangled

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 27 15:01:18 PDT 2021


bulbazord added inline comments.


================
Comment at: lldb/source/Core/Mangled.cpp:322
   if (preference == ePreferDemangledWithoutArguments) {
-    return GetDemangledNameWithoutArguments(m_mangled, demangled);
+    if (Language *lang = Language::FindPlugin(GuessLanguage())) {
+      return lang->GetDemangledFunctionNameWithoutArguments(*this);
----------------
clayborg wrote:
> Maybe we should make a Language::FindPlugin(...) that like:
> ```
> Language *Language::FindPlugin(Mangled::ManglingScheme mangling_scheme);
> ```
> Should be easy to add since this change is kind of about refactoring and putting the code into plug-ins. It is essentially what "lldb::LanguageType Mangled::GuessLanguage() const" is doing. That code could be moved to where Language::FindPlugin(...) lives.
`GuessLanguage` has a bunch of uses outside of `Mangled` itself, so I think that would make more sense if we performed other refactors first.

I don't think putting this into another `Language::FindPlugin` function is a good idea because (as I understand it) mangling schemes aren't specific to languages. 


================
Comment at: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:67
 
+ConstString CPlusPlusLanguage::GetDemangledFunctionNameWithoutArguments(
+    Mangled mangled) const {
----------------
clayborg wrote:
> We are doing the work over and over here. Who calls this? Is this something we should think about caching? It would be easy to make a map of ConstString (demangled name) to ConstString (result of this function call) and we can possibly improve the efficiency of this. 
The only use of `GetDemangledFunctionNameWithoutArguments` is `Mangled::GetName`, and the only time it's ever actually executed is if the argument to `GetName` is `ePreferDemangledWithoutArguments`.  This happens twice from what I can see: `Symbol::GetNameNoArguments` and `Function::GetNameNoArguments`. I believe these methods are used for dumping and formatting.

Not sure how often they are actually used though. May be useful to profile and potentially cache if it's used enough?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105215



More information about the lldb-commits mailing list