Skip to content

Commit 0a96161

Browse files
authored
[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.
1 parent b80a157 commit 0a96161

File tree

4 files changed

+10
-22
lines changed

4 files changed

+10
-22
lines changed

lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ namespace lldb_private {
2222
class DumpValueObjectOptions {
2323
public:
2424
struct PointerDepth {
25-
enum class Mode { Always, Default, Never } m_mode;
26-
uint32_t m_count;
25+
uint32_t m_count = 0;
2726

2827
PointerDepth Decremented() const {
2928
if (m_count > 0)
30-
return PointerDepth{m_mode, m_count - 1};
31-
return PointerDepth{m_mode, m_count};
29+
return {m_count - 1};
30+
return *this;
3231
}
3332

3433
bool CanAllowExpansion() const;
@@ -65,8 +64,7 @@ class DumpValueObjectOptions {
6564

6665
DumpValueObjectOptions(ValueObject &valobj);
6766

68-
DumpValueObjectOptions &
69-
SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never, 0});
67+
DumpValueObjectOptions &SetMaximumPointerDepth(uint32_t depth);
7068

7169
DumpValueObjectOptions &SetMaximumDepth(uint32_t depth, bool is_default);
7270

lldb/source/DataFormatters/DumpValueObjectOptions.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ using namespace lldb;
1414
using namespace lldb_private;
1515

1616
DumpValueObjectOptions::DumpValueObjectOptions()
17-
: m_summary_sp(), m_root_valobj_name(),
18-
m_max_ptr_depth(PointerDepth{PointerDepth::Mode::Default, 0}),
19-
m_decl_printing_helper(), m_child_printing_decider(),
20-
m_pointer_as_array(), m_use_synthetic(true),
17+
: m_summary_sp(), m_root_valobj_name(), m_decl_printing_helper(),
18+
m_child_printing_decider(), m_pointer_as_array(), m_use_synthetic(true),
2119
m_scope_already_checked(false), m_flat_output(false), m_ignore_cap(false),
2220
m_show_types(false), m_show_location(false), m_use_objc(false),
2321
m_hide_root_type(false), m_hide_root_name(false), m_hide_name(false),
@@ -33,8 +31,8 @@ DumpValueObjectOptions::DumpValueObjectOptions(ValueObject &valobj)
3331
}
3432

3533
DumpValueObjectOptions &
36-
DumpValueObjectOptions::SetMaximumPointerDepth(PointerDepth depth) {
37-
m_max_ptr_depth = depth;
34+
DumpValueObjectOptions::SetMaximumPointerDepth(uint32_t depth) {
35+
m_max_ptr_depth = {depth};
3836
return *this;
3937
}
4038

lldb/source/DataFormatters/ValueObjectPrinter.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,7 @@ ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed,
503503
}
504504

505505
bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion() const {
506-
switch (m_mode) {
507-
case Mode::Always:
508-
case Mode::Default:
509-
return m_count > 0;
510-
case Mode::Never:
511-
return false;
512-
}
513-
return false;
506+
return m_count > 0;
514507
}
515508

516509
bool ValueObjectPrinter::ShouldPrintChildren(

lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ DumpValueObjectOptions OptionGroupValueObjectDisplay::GetAsDumpOptions(
190190
LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity,
191191
lldb::Format format, lldb::TypeSummaryImplSP summary_sp) {
192192
DumpValueObjectOptions options;
193-
options.SetMaximumPointerDepth(
194-
{DumpValueObjectOptions::PointerDepth::Mode::Always, ptr_depth});
193+
options.SetMaximumPointerDepth(ptr_depth);
195194
if (use_objc)
196195
options.SetShowSummary(false);
197196
else

0 commit comments

Comments
 (0)