Skip to content

Commit f220ea2

Browse files
committed
[lldb][Mangled] Add API to force re-demangling a Mangled object (llvm#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. llvm#131836
1 parent 9c830ce commit f220ea2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lldb/include/lldb/Core/Mangled.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ class Mangled {
278278
void Encode(DataEncoder &encoder, ConstStringTable &strtab) const;
279279

280280
private:
281+
/// If \c force is \c false, this function will re-use the previously
282+
/// demangled name (if any). If \c force is \c true (or the mangled name
283+
/// on this object was not previously demangled), demangle and cache the
284+
/// name.
285+
ConstString GetDemangledNameImpl(bool force) const;
286+
281287
/// The mangled version of the name.
282288
ConstString m_mangled;
283289

lldb/source/Core/Mangled.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,19 +265,24 @@ bool Mangled::GetRichManglingInfo(RichManglingContext &context,
265265
llvm_unreachable("Fully covered switch above!");
266266
}
267267

268+
ConstString Mangled::GetDemangledName() const {
269+
return GetDemangledNameImpl(/*force=*/false);
270+
}
271+
268272
// Generate the demangled name on demand using this accessor. Code in this
269273
// class will need to use this accessor if it wishes to decode the demangled
270274
// name. The result is cached and will be kept until a new string value is
271275
// supplied to this object, or until the end of the object's lifetime.
272-
ConstString Mangled::GetDemangledName() const {
276+
ConstString Mangled::GetDemangledNameImpl(bool force) const {
273277
if (!m_mangled)
274278
return m_demangled;
275279

276280
// Re-use previously demangled names.
277-
if (!m_demangled.IsNull())
281+
if (!force && !m_demangled.IsNull())
278282
return m_demangled;
279283

280-
if (m_mangled.GetMangledCounterpart(m_demangled) && !m_demangled.IsNull())
284+
if (!force && m_mangled.GetMangledCounterpart(m_demangled) &&
285+
!m_demangled.IsNull())
281286
return m_demangled;
282287

283288
// We didn't already mangle this name, demangle it and if all goes well

0 commit comments

Comments
 (0)