Skip to content

Conversation

@Michael137
Copy link
Member

We've been seen (very sporadic) lifetime issues around this area. We noticed that GetMangledName has two accessors, one of which returns a non-const reference. I audited all the callsites and no users of this overload actually mutate the ConstString itself (which is a suspicious thing to do anyway since it's just a wrapper around a const char*).

This patch removes the redundant overload.

rdar://161128180

…ccessor

We've been seen (very sporadic) lifetime issues around this area. We
noticed that `GetMangledName` has two accessors, one of which returns a
non-const reference. I audited all the callsites and no users of this
overload actually mutate the `ConstString` itself (which is a suspicious
thing to do anyway since it's just a wrapper around a `const char*`).

This patch removes the redundant overload.

rdar://161128180
@llvmbot
Copy link
Member

llvmbot commented Oct 1, 2025

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

Changes

We've been seen (very sporadic) lifetime issues around this area. We noticed that GetMangledName has two accessors, one of which returns a non-const reference. I audited all the callsites and no users of this overload actually mutate the ConstString itself (which is a suspicious thing to do anyway since it's just a wrapper around a const char*).

This patch removes the redundant overload.

rdar://161128180


Full diff: https://github.com/llvm/llvm-project/pull/161495.diff

1 Files Affected:

  • (modified) lldb/include/lldb/Core/Mangled.h (+1-7)
diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h
index 47f1c6a8d80b7..1dcc34b4989dd 100644
--- a/lldb/include/lldb/Core/Mangled.h
+++ b/lldb/include/lldb/Core/Mangled.h
@@ -148,13 +148,7 @@ class Mangled {
   /// Mangled name get accessor.
   ///
   /// \return
-  ///     A reference to the mangled name string object.
-  ConstString &GetMangledName() { return m_mangled; }
-
-  /// Mangled name get accessor.
-  ///
-  /// \return
-  ///     A const reference to the mangled name string object.
+  ///     A the mangled name string object.
   ConstString GetMangledName() const { return m_mangled; }
 
   /// Best name get accessor.

Copy link
Collaborator

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very pointless overload anyway.

@Michael137 Michael137 merged commit f33564b into llvm:main Oct 1, 2025
9 checks passed
@Michael137 Michael137 deleted the lldb/mangled-accessor-cleanup branch October 1, 2025 15:26
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
…ccessor (llvm#161495)

We've been seen (very sporadic) lifetime issues around this area. We
noticed that `GetMangledName` has two accessors, one of which returns a
non-const reference. I audited all the callsites and no users of this
overload actually mutate the `ConstString` itself (which is a suspicious
thing to do anyway since it's just a wrapper around a `const char*`).

This patch removes the redundant overload.

rdar://161128180
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants