[Lldb-commits] [lldb] 0a96161 - [lldb] Simplify DumpValueObjectOptions::PointerDepth (NFC) (#117504)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Dec 2 16:23:28 PST 2024
Author: Dave Lee
Date: 2024-12-02T16:23:26-08:00
New Revision: 0a96161beb161933e64e188bfb0754df494c3a58
URL: https://github.com/llvm/llvm-project/commit/0a96161beb161933e64e188bfb0754df494c3a58
DIFF: https://github.com/llvm/llvm-project/commit/0a96161beb161933e64e188bfb0754df494c3a58.diff
LOG: [lldb] Simplify DumpValueObjectOptions::PointerDepth (NFC) (#117504)
`Mode::Always` and `Mode::Default` are handled identically.
`Mode::Never` is the same as having a count of 0.
Added:
Modified:
lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
lldb/source/DataFormatters/DumpValueObjectOptions.cpp
lldb/source/DataFormatters/ValueObjectPrinter.cpp
lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
index c7f8cccc116c48..ce15963ab5662c 100644
--- a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -22,13 +22,12 @@ namespace lldb_private {
class DumpValueObjectOptions {
public:
struct PointerDepth {
- enum class Mode { Always, Default, Never } m_mode;
- uint32_t m_count;
+ uint32_t m_count = 0;
PointerDepth Decremented() const {
if (m_count > 0)
- return PointerDepth{m_mode, m_count - 1};
- return PointerDepth{m_mode, m_count};
+ return {m_count - 1};
+ return *this;
}
bool CanAllowExpansion() const;
@@ -65,8 +64,7 @@ class DumpValueObjectOptions {
DumpValueObjectOptions(ValueObject &valobj);
- DumpValueObjectOptions &
- SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never, 0});
+ DumpValueObjectOptions &SetMaximumPointerDepth(uint32_t depth);
DumpValueObjectOptions &SetMaximumDepth(uint32_t depth, bool is_default);
diff --git a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
index 18d590d47d9a0c..b952fb643f13ef 100644
--- a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
+++ b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
@@ -14,10 +14,8 @@ using namespace lldb;
using namespace lldb_private;
DumpValueObjectOptions::DumpValueObjectOptions()
- : m_summary_sp(), m_root_valobj_name(),
- m_max_ptr_depth(PointerDepth{PointerDepth::Mode::Default, 0}),
- m_decl_printing_helper(), m_child_printing_decider(),
- m_pointer_as_array(), m_use_synthetic(true),
+ : m_summary_sp(), m_root_valobj_name(), m_decl_printing_helper(),
+ m_child_printing_decider(), m_pointer_as_array(), m_use_synthetic(true),
m_scope_already_checked(false), m_flat_output(false), m_ignore_cap(false),
m_show_types(false), m_show_location(false), m_use_objc(false),
m_hide_root_type(false), m_hide_root_name(false), m_hide_name(false),
@@ -33,8 +31,8 @@ DumpValueObjectOptions::DumpValueObjectOptions(ValueObject &valobj)
}
DumpValueObjectOptions &
-DumpValueObjectOptions::SetMaximumPointerDepth(PointerDepth depth) {
- m_max_ptr_depth = depth;
+DumpValueObjectOptions::SetMaximumPointerDepth(uint32_t depth) {
+ m_max_ptr_depth = {depth};
return *this;
}
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index face38253efab8..01e604e019f25f 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -503,14 +503,7 @@ ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed,
}
bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion() const {
- switch (m_mode) {
- case Mode::Always:
- case Mode::Default:
- return m_count > 0;
- case Mode::Never:
- return false;
- }
- return false;
+ return m_count > 0;
}
bool ValueObjectPrinter::ShouldPrintChildren(
diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 0e8c1f4b5f1d9a..d633c469e603ec 100644
--- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -190,8 +190,7 @@ DumpValueObjectOptions OptionGroupValueObjectDisplay::GetAsDumpOptions(
LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity,
lldb::Format format, lldb::TypeSummaryImplSP summary_sp) {
DumpValueObjectOptions options;
- options.SetMaximumPointerDepth(
- {DumpValueObjectOptions::PointerDepth::Mode::Always, ptr_depth});
+ options.SetMaximumPointerDepth(ptr_depth);
if (use_objc)
options.SetShowSummary(false);
else
More information about the lldb-commits
mailing list