Author: Dave Lee
Date: 2026-06-24T13:57:25-07:00
New Revision: fa538c0b3af533e296cbfc0dd018ef94cf3607ed

URL: 
https://github.com/llvm/llvm-project/commit/fa538c0b3af533e296cbfc0dd018ef94cf3607ed
DIFF: 
https://github.com/llvm/llvm-project/commit/fa538c0b3af533e296cbfc0dd018ef94cf3607ed.diff

LOG: [lldb] Remove unused MemorySize methods (NFC) (#205463)

These `MemorySize` methods are unused. There are two remaining which are
used: `FileSpec::MemorySize` and `ConstString::MemorySize`.

Added: 
    

Modified: 
    lldb/include/lldb/Core/Address.h
    lldb/include/lldb/Core/AddressRange.h
    lldb/include/lldb/Core/Declaration.h
    lldb/include/lldb/Core/Mangled.h
    lldb/include/lldb/Symbol/Block.h
    lldb/include/lldb/Symbol/Function.h
    lldb/include/lldb/Symbol/Variable.h
    lldb/include/lldb/Symbol/VariableList.h
    lldb/include/lldb/Utility/FileSpecList.h
    lldb/source/Core/Address.cpp
    lldb/source/Core/Declaration.cpp
    lldb/source/Core/Mangled.cpp
    lldb/source/Symbol/Block.cpp
    lldb/source/Symbol/Function.cpp
    lldb/source/Symbol/Variable.cpp
    lldb/source/Symbol/VariableList.cpp
    lldb/source/Utility/FileSpecList.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Core/Address.h 
b/lldb/include/lldb/Core/Address.h
index 15fc30a2e3f92..c851237058c73 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -354,12 +354,6 @@ class Address {
   ///     otherwise.
   bool IsValid() const { return m_offset != LLDB_INVALID_ADDRESS; }
 
-  /// Get the memory cost of this object.
-  ///
-  /// \return
-  ///     The number of bytes that this object occupies in memory.
-  size_t MemorySize() const;
-
   /// Resolve a file virtual address using a section list.
   ///
   /// Given a list of sections, attempt to resolve \a addr as an offset into

diff  --git a/lldb/include/lldb/Core/AddressRange.h 
b/lldb/include/lldb/Core/AddressRange.h
index af26bb3b351a3..08cfffc4d1d5b 100644
--- a/lldb/include/lldb/Core/AddressRange.h
+++ b/lldb/include/lldb/Core/AddressRange.h
@@ -222,16 +222,6 @@ class AddressRange {
   ///     The size in bytes of this address range.
   lldb::addr_t GetByteSize() const { return m_byte_size; }
 
-  /// Get the memory cost of this object.
-  ///
-  /// \return
-  ///     The number of bytes that this object occupies in memory.
-  size_t MemorySize() const {
-    // Noting special for the memory size of a single AddressRange object, it
-    // is just the size of itself.
-    return sizeof(AddressRange);
-  }
-
   /// Set accessor for the byte size of this range.
   ///
   /// \param[in] byte_size

diff  --git a/lldb/include/lldb/Core/Declaration.h 
b/lldb/include/lldb/Core/Declaration.h
index adfe0da9cc7c8..df7ff70f94025 100644
--- a/lldb/include/lldb/Core/Declaration.h
+++ b/lldb/include/lldb/Core/Declaration.h
@@ -150,14 +150,6 @@ class Declaration {
     return m_file && m_line != 0 && m_line != LLDB_INVALID_LINE_NUMBER;
   }
 
-  /// Get the memory cost of this object.
-  ///
-  /// \return
-  ///     The number of bytes that this object occupies in memory.
-  ///     The returned value does not include the bytes for any
-  ///     shared string values.
-  size_t MemorySize() const;
-
   /// Set accessor for the declaration file specification.
   ///
   /// \param[in] file_spec

diff  --git a/lldb/include/lldb/Core/Mangled.h 
b/lldb/include/lldb/Core/Mangled.h
index 6c6f2574ad22e..1c7bbeb05a37d 100644
--- a/lldb/include/lldb/Core/Mangled.h
+++ b/lldb/include/lldb/Core/Mangled.h
@@ -198,16 +198,6 @@ class Mangled {
   }
   bool NameMatches(const RegularExpression &regex) const;
 
-  /// Get the memory cost of this object.
-  ///
-  /// Return the size in bytes that this object takes in memory. This returns
-  /// the size in bytes of this object, not any shared string values it may
-  /// refer to.
-  ///
-  /// \return
-  ///     The number of bytes that this object occupies in memory.
-  size_t MemorySize() const;
-
   /// Set the string value in this object.
   ///
   /// This version auto detects if the string is mangled by inspecting the

diff  --git a/lldb/include/lldb/Symbol/Block.h 
b/lldb/include/lldb/Symbol/Block.h
index 601895631e148..ca7a22e81c855 100644
--- a/lldb/include/lldb/Symbol/Block.h
+++ b/lldb/include/lldb/Symbol/Block.h
@@ -277,15 +277,6 @@ class Block : public UserID, public SymbolContextScope {
 
   CompilerDeclContext GetDeclContext();
 
-  /// Get the memory cost of this object.
-  ///
-  /// Returns the cost of this object plus any owned objects from the ranges,
-  /// variables, and inline function information.
-  ///
-  /// \return
-  ///     The number of bytes that this object occupies in memory.
-  size_t MemorySize() const;
-
   /// Set accessor for any inlined function information.
   ///
   /// \param[in] name

diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 5f5896ea05a26..7b707b4d72540 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -105,14 +105,6 @@ class FunctionInfo {
   ///     A const reference to the method name object.
   ConstString GetName() const;
 
-  /// Get the memory cost of this object.
-  ///
-  /// \return
-  ///     The number of bytes that this object occupies in memory.
-  ///     The returned value does not include the bytes for any
-  ///     shared string values.
-  virtual size_t MemorySize() const;
-
 protected:
   /// Function method name (not a mangled name).
   ConstString m_name;
@@ -231,14 +223,6 @@ class InlineFunctionInfo : public FunctionInfo {
   ///     A const reference to the mangled name object.
   const Mangled &GetMangled() const;
 
-  /// Get the memory cost of this object.
-  ///
-  /// \return
-  ///     The number of bytes that this object occupies in memory.
-  ///     The returned value does not include the bytes for any
-  ///     shared string values.
-  size_t MemorySize() const override;
-
 private:
   /// Mangled inlined function name (can be empty if there is no mangled
   /// information).
@@ -579,14 +563,6 @@ class Function : public UserID, public SymbolContextScope {
   /// \see SymbolContextScope
   void DumpSymbolContext(Stream *s) override;
 
-  /// Get the memory cost of this object.
-  ///
-  /// \return
-  ///     The number of bytes that this object occupies in memory.
-  ///     The returned value does not include the bytes for any
-  ///     shared string values.
-  size_t MemorySize() const;
-
   /// Get whether compiler optimizations were enabled for this function
   ///
   /// The debug information may provide information about whether this

diff  --git a/lldb/include/lldb/Symbol/Variable.h 
b/lldb/include/lldb/Symbol/Variable.h
index 4950205d3d43a..1e6a36d584212 100644
--- a/lldb/include/lldb/Symbol/Variable.h
+++ b/lldb/include/lldb/Symbol/Variable.h
@@ -88,8 +88,6 @@ class Variable : public UserID, public 
std::enable_shared_from_this<Variable> {
   // the location that contains this address.
   bool DumpLocations(Stream *s, const Address &address);
 
-  size_t MemorySize() const;
-
   void CalculateSymbolContext(SymbolContext *sc);
 
   bool IsInScope(StackFrame *frame);

diff  --git a/lldb/include/lldb/Symbol/VariableList.h 
b/lldb/include/lldb/Symbol/VariableList.h
index cacbe4cdde8fd..12c25da0fe04f 100644
--- a/lldb/include/lldb/Symbol/VariableList.h
+++ b/lldb/include/lldb/Symbol/VariableList.h
@@ -64,8 +64,6 @@ class VariableList {
 
   uint32_t FindIndexForVariable(Variable *variable);
 
-  size_t MemorySize() const;
-
   size_t GetSize() const;
   bool Empty() const { return m_variables.empty(); }
 

diff  --git a/lldb/include/lldb/Utility/FileSpecList.h 
b/lldb/include/lldb/Utility/FileSpecList.h
index 21c9aed78953e..571bc65209507 100644
--- a/lldb/include/lldb/Utility/FileSpecList.h
+++ b/lldb/include/lldb/Utility/FileSpecList.h
@@ -202,16 +202,6 @@ class FileSpecList {
   ///     returned.
   const FileSpec &GetFileSpecAtIndex(size_t idx) const;
 
-  /// Get the memory cost of this object.
-  ///
-  /// Return the size in bytes that this object takes in memory. This returns
-  /// the size in bytes of this object, not any shared string values it may
-  /// refer to.
-  ///
-  /// \return
-  ///     The number of bytes that this object occupies in memory.
-  size_t MemorySize() const;
-
   bool IsEmpty() const { return m_files.empty(); }
 
   /// Get the number of files in the file list.

diff  --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp
index a5f620752acfd..29efb204d7115 100644
--- a/lldb/source/Core/Address.cpp
+++ b/lldb/source/Core/Address.cpp
@@ -958,12 +958,6 @@ int Address::CompareModulePointerAndOffset(const Address 
&a, const Address &b) {
   return 0;
 }
 
-size_t Address::MemorySize() const {
-  // Noting special for the memory size of a single Address object, it is just
-  // the size of itself.
-  return sizeof(Address);
-}
-
 // NOTE: Be careful using this operator. It can correctly compare two
 // addresses from the same Module correctly. It can't compare two addresses
 // from 
diff erent modules in any meaningful way, but it will compare the module

diff  --git a/lldb/source/Core/Declaration.cpp 
b/lldb/source/Core/Declaration.cpp
index a485c4b9ba48a..5eb574cef1767 100644
--- a/lldb/source/Core/Declaration.cpp
+++ b/lldb/source/Core/Declaration.cpp
@@ -53,8 +53,6 @@ bool Declaration::DumpStopContext(Stream *s, bool 
show_fullpaths) const {
   return false;
 }
 
-size_t Declaration::MemorySize() const { return sizeof(Declaration); }
-
 int Declaration::Compare(const Declaration &a, const Declaration &b) {
   int result = FileSpec::Compare(a.m_file, b.m_file, true);
   if (result)

diff  --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 3f72571cee9ca..62c4a9131a6f7 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -407,13 +407,6 @@ void Mangled::DumpDebug(Stream *s) const {
   m_demangled.DumpDebug(s);
 }
 
-// Return the size in byte that this object takes in memory. The size includes
-// the size of the objects it owns, and not the strings that it references
-// because they are shared strings.
-size_t Mangled::MemorySize() const {
-  return m_mangled.MemorySize() + m_demangled.MemorySize();
-}
-
 // We "guess" the language because we can't determine a symbol's language from
 // it's name.  For example, a Pascal symbol can be mangled using the C++
 // Itanium scheme, and defined in a compilation unit within the same module as

diff  --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp
index 3de3e5eecbf35..1f082d577f9e3 100644
--- a/lldb/source/Symbol/Block.cpp
+++ b/lldb/source/Symbol/Block.cpp
@@ -367,16 +367,6 @@ void Block::AddRange(const Range &range) {
   m_ranges.Append(range);
 }
 
-// Return the current number of bytes that this object occupies in memory
-size_t Block::MemorySize() const {
-  size_t mem_size = sizeof(Block) + m_ranges.GetSize() * sizeof(Range);
-  if (m_inlineInfoSP.get())
-    mem_size += m_inlineInfoSP->MemorySize();
-  if (m_variable_list_sp.get())
-    mem_size += m_variable_list_sp->MemorySize();
-  return mem_size;
-}
-
 BlockSP Block::CreateChild(user_id_t uid) {
   m_children.push_back(std::shared_ptr<Block>(new Block(uid, *this)));
   return m_children.back();

diff  --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index 359e9369c07c2..17c7e9bb36698 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -59,10 +59,6 @@ const Declaration &FunctionInfo::GetDeclaration() const {
 
 ConstString FunctionInfo::GetName() const { return m_name; }
 
-size_t FunctionInfo::MemorySize() const {
-  return m_name.MemorySize() + m_declaration.MemorySize();
-}
-
 InlineFunctionInfo::InlineFunctionInfo(const char *name,
                                        llvm::StringRef mangled,
                                        const Declaration *decl_ptr,
@@ -116,10 +112,6 @@ Mangled &InlineFunctionInfo::GetMangled() { return 
m_mangled; }
 
 const Mangled &InlineFunctionInfo::GetMangled() const { return m_mangled; }
 
-size_t InlineFunctionInfo::MemorySize() const {
-  return FunctionInfo::MemorySize() + m_mangled.MemorySize();
-}
-
 /// @name Call site related structures
 /// @{
 
@@ -509,11 +501,6 @@ void Function::DumpSymbolContext(Stream *s) {
   s->Printf(", Function{0x%8.8" PRIx64 "}", GetID());
 }
 
-size_t Function::MemorySize() const {
-  size_t mem_size = sizeof(Function) + m_block.MemorySize();
-  return mem_size;
-}
-
 bool Function::GetIsOptimized() {
   bool result = false;
 

diff  --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 3f280d9cec2c6..70a61fc7789c9 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -200,8 +200,6 @@ bool Variable::DumpDeclaration(Stream *s, bool 
show_fullpaths,
   return dumped_declaration_info;
 }
 
-size_t Variable::MemorySize() const { return sizeof(Variable); }
-
 CompilerDeclContext Variable::GetDeclContext() {
   Type *type = GetType();
   if (type)

diff  --git a/lldb/source/Symbol/VariableList.cpp 
b/lldb/source/Symbol/VariableList.cpp
index 9ee2994a3dc12..b9f2494d4a5bd 100644
--- a/lldb/source/Symbol/VariableList.cpp
+++ b/lldb/source/Symbol/VariableList.cpp
@@ -142,14 +142,6 @@ uint32_t VariableList::FindIndexForVariable(Variable 
*variable) {
   return UINT32_MAX;
 }
 
-size_t VariableList::MemorySize() const {
-  size_t mem_size = sizeof(VariableList);
-  const_iterator pos, end = m_variables.end();
-  for (pos = m_variables.begin(); pos != end; ++pos)
-    mem_size += (*pos)->MemorySize();
-  return mem_size;
-}
-
 size_t VariableList::GetSize() const { return m_variables.size(); }
 
 void VariableList::Dump(Stream *s, bool show_context) const {

diff  --git a/lldb/source/Utility/FileSpecList.cpp 
b/lldb/source/Utility/FileSpecList.cpp
index bdbdd5841df4b..930d89e4a3e62 100644
--- a/lldb/source/Utility/FileSpecList.cpp
+++ b/lldb/source/Utility/FileSpecList.cpp
@@ -217,19 +217,5 @@ SupportFileNSP 
SupportFileList::GetSupportFileAtIndex(size_t idx) const {
   return std::make_shared<SupportFile>();
 }
 
-// Return the size in bytes that this object takes in memory. This returns the
-// size in bytes of this object's member variables and any FileSpec objects its
-// member variables contain, the result doesn't not include the string values
-// for the directories any filenames as those are in shared string pools.
-size_t FileSpecList::MemorySize() const {
-  size_t mem_size = sizeof(FileSpecList);
-  collection::const_iterator pos, end = m_files.end();
-  for (pos = m_files.begin(); pos != end; ++pos) {
-    mem_size += pos->MemorySize();
-  }
-
-  return mem_size;
-}
-
 // Return the number of files in the file spec list.
 size_t FileSpecList::GetSize() const { return m_files.size(); }


        
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to