summaryrefslogtreecommitdiff
path: root/lldb
diff options
context:
space:
mode:
authorDave Lee <davelee.com@gmail.com>2023-05-08 10:13:33 -0700
committerDave Lee <davelee.com@gmail.com>2023-05-15 15:20:48 -0700
commit8d4f0e079554c5eb5c9effda58dbda3b17f03160 (patch)
treef87409f98b5dc1732115e363584a418412cc7bc9 /lldb
parent4a899a35182be83ba46ae7906f0ce80ae800ef35 (diff)
downloadllvm-8d4f0e079554c5eb5c9effda58dbda3b17f03160.tar.gz
[lldb] Refine call to decl printing helper (NFC)
When `ValueObjectPrinter` calls its `m_decl_printing_helper`, not all state is passed to the helper. In particular, the helper doesn't have access to `m_curr_depth`, and thus can't act on the logic within `ShouldShowName`. To address this, this change passes in a modified copy of `m_options`. The modified copy has has `m_hide_name` set according to the results of `ShouldShowName`. This allows helper functions to know whether the name should be shown or hidden, without having access to `ValueObjectPrinter`'s full state. This is NFC in mainline lldb, as the only decl printing helper doesn't make use of this. However in swift-lldb at least, there are decl printing helpers that do need this information passed to them. See https://github.com/apple/llvm-project/pull/6795 where a test is also included. Differential Revision: https://reviews.llvm.org/D150129
Diffstat (limited to 'lldb')
-rw-r--r--lldb/source/DataFormatters/ValueObjectPrinter.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index 8e44f723165b..bde999a7a8bc 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -300,9 +300,14 @@ void ValueObjectPrinter::PrintDecl() {
ConstString type_name_cstr(typeName.GetString());
ConstString var_name_cstr(varName.GetString());
+ DumpValueObjectOptions decl_print_options = m_options;
+ // Pass printing helpers an option object that indicates whether the name
+ // should be shown or hidden.
+ decl_print_options.SetHideName(!ShouldShowName());
+
StreamString dest_stream;
if (m_options.m_decl_printing_helper(type_name_cstr, var_name_cstr,
- m_options, dest_stream)) {
+ decl_print_options, dest_stream)) {
decl_printed = true;
m_stream->PutCString(dest_stream.GetString());
}