https://github.com/bulbazord created https://github.com/llvm/llvm-project/pull/176459
This method is only non-const because it lazily computes the information and caches it. This means users of Symbol must otherwise carry around a pointer or reference to a mutable Symbol. I would like to minimize the places that need a mutable pointer/reference to Symbols if possible. >From 1dc6f51fcf39c16d8891d123a65f73961cafcf91 Mon Sep 17 00:00:00 2001 From: Alex Langford <[email protected]> Date: Fri, 16 Jan 2026 11:05:28 -0800 Subject: [PATCH] [lldb] Mark Symbol::GetPrologueByteSize as const This method is only non-const because it lazily computes the information and caches it. This means users of Symbol must otherwise carry around a pointer or reference to a mutable Symbol. I would like to minimize the places that need a mutable pointer/reference to Symbols if possible. --- lldb/include/lldb/Symbol/Symbol.h | 8 ++++---- lldb/source/Symbol/Symbol.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h index 1f9d222b6ab29..648703591fc36 100644 --- a/lldb/include/lldb/Symbol/Symbol.h +++ b/lldb/include/lldb/Symbol/Symbol.h @@ -221,7 +221,7 @@ class Symbol : public SymbolContextScope { // If m_type is "Code" or "Function" then this will return the prologue size // in bytes, else it will return zero. - uint32_t GetPrologueByteSize(); + uint32_t GetPrologueByteSize() const; bool GetDemangledNameIsSynthesized() const { return m_demangled_is_synthesized; @@ -320,9 +320,9 @@ class Symbol : public SymbolContextScope { uint32_t m_uid = LLDB_INVALID_SYMBOL_ID; // User ID (usually the original // symbol table index) - uint16_t m_type_data = 0; // data specific to m_type - uint16_t m_type_data_resolved : 1, // True if the data in m_type_data has - // already been calculated + mutable uint16_t m_type_data = 0; // data specific to m_type + mutable uint16_t m_type_data_resolved : 1, // True if the data in m_type_data + // has already been calculated m_is_synthetic : 1, // non-zero if this symbol is not actually in the // symbol table, but synthesized from other info in // the object file. diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index 40497dbccc5c3..45118b49becf4 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -310,7 +310,7 @@ void Symbol::Dump(Stream *s, Target *target, uint32_t index, } } -uint32_t Symbol::GetPrologueByteSize() { +uint32_t Symbol::GetPrologueByteSize() const { if (m_type == eSymbolTypeCode || m_type == eSymbolTypeResolver) { if (!m_type_data_resolved) { m_type_data_resolved = true; _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
