Author: Michael Buch Date: 2025-04-25T10:04:27+01:00 New Revision: f220ea2947b9c8b1e33db65b008086d47fa72af3
URL: https://github.com/llvm/llvm-project/commit/f220ea2947b9c8b1e33db65b008086d47fa72af3 DIFF: https://github.com/llvm/llvm-project/commit/f220ea2947b9c8b1e33db65b008086d47fa72af3.diff LOG: [lldb][Mangled] Add API to force re-demangling a Mangled object (#131836) Add version of GetDemangledName that will force re-demangling. This is required because LLDB will SetDemangledName without going through the demangler. So we need a way to force demangling to set the m_demangled_info member when we need it. https://github.com/llvm/llvm-project/pull/131836 Added: Modified: lldb/include/lldb/Core/Mangled.h lldb/source/Core/Mangled.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 7db63eeeb6ee0..1dca1f0e2b139 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -278,6 +278,12 @@ class Mangled { void Encode(DataEncoder &encoder, ConstStringTable &strtab) const; private: + /// If \c force is \c false, this function will re-use the previously + /// demangled name (if any). If \c force is \c true (or the mangled name + /// on this object was not previously demangled), demangle and cache the + /// name. + ConstString GetDemangledNameImpl(bool force) const; + /// The mangled version of the name. ConstString m_mangled; diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index 56836a6e5663e..b69be163ca233 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -265,19 +265,24 @@ bool Mangled::GetRichManglingInfo(RichManglingContext &context, llvm_unreachable("Fully covered switch above!"); } +ConstString Mangled::GetDemangledName() const { + return GetDemangledNameImpl(/*force=*/false); +} + // Generate the demangled name on demand using this accessor. Code in this // class will need to use this accessor if it wishes to decode the demangled // name. The result is cached and will be kept until a new string value is // supplied to this object, or until the end of the object's lifetime. -ConstString Mangled::GetDemangledName() const { +ConstString Mangled::GetDemangledNameImpl(bool force) const { if (!m_mangled) return m_demangled; // Re-use previously demangled names. - if (!m_demangled.IsNull()) + if (!force && !m_demangled.IsNull()) return m_demangled; - if (m_mangled.GetMangledCounterpart(m_demangled) && !m_demangled.IsNull()) + if (!force && m_mangled.GetMangledCounterpart(m_demangled) && + !m_demangled.IsNull()) return m_demangled; // We didn't already mangle this name, demangle it and if all goes well _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits