aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/DataFormatters/ValueObjectPrinter.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-06-13 19:31:46 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-06-13 19:37:19 +0000
commite8d8bef961a50d4dc22501cde4fb9fb0be1b2532 (patch)
tree94f04805f47bb7c59ae29690d8952b6074fff602 /contrib/llvm-project/lldb/source/DataFormatters/ValueObjectPrinter.cpp
parentbb130ff39747b94592cb26d71b7cb097b9a4ea6b (diff)
parentb60736ec1405bb0a8dd40989f67ef4c93da068ab (diff)
downloadsrc-e8d8bef961a50d4dc22501cde4fb9fb0be1b2532.tar.gz
src-e8d8bef961a50d4dc22501cde4fb9fb0be1b2532.zip
Diffstat (limited to 'contrib/llvm-project/lldb/source/DataFormatters/ValueObjectPrinter.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/DataFormatters/ValueObjectPrinter.cpp47
1 files changed, 30 insertions, 17 deletions
diff --git a/contrib/llvm-project/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/contrib/llvm-project/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index c8a306334cf5..082ad344d2d1 100644
--- a/contrib/llvm-project/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/contrib/llvm-project/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -355,22 +355,33 @@ void ValueObjectPrinter::GetValueSummaryError(std::string &value,
if (err_cstr)
error.assign(err_cstr);
- if (ShouldPrintValueObject()) {
- if (IsNil())
- summary.assign("nil");
- else if (IsUninitialized())
- summary.assign("<uninitialized>");
- else if (m_options.m_omit_summary_depth == 0) {
- TypeSummaryImpl *entry = GetSummaryFormatter();
- if (entry)
- m_valobj->GetSummaryAsCString(entry, summary,
- m_options.m_varformat_language);
- else {
- const char *sum_cstr =
- m_valobj->GetSummaryAsCString(m_options.m_varformat_language);
- if (sum_cstr)
- summary.assign(sum_cstr);
- }
+ if (!ShouldPrintValueObject())
+ return;
+
+ if (IsNil()) {
+ lldb::LanguageType lang_type =
+ (m_options.m_varformat_language == lldb::eLanguageTypeUnknown)
+ ? m_valobj->GetPreferredDisplayLanguage()
+ : m_options.m_varformat_language;
+ if (Language *lang_plugin = Language::FindPlugin(lang_type)) {
+ summary.assign(lang_plugin->GetNilReferenceSummaryString().str());
+ } else {
+ // We treat C as the fallback language rather than as a separate Language
+ // plugin.
+ summary.assign("NULL");
+ }
+ } else if (IsUninitialized()) {
+ summary.assign("<uninitialized>");
+ } else if (m_options.m_omit_summary_depth == 0) {
+ TypeSummaryImpl *entry = GetSummaryFormatter();
+ if (entry) {
+ m_valobj->GetSummaryAsCString(entry, summary,
+ m_options.m_varformat_language);
+ } else {
+ const char *sum_cstr =
+ m_valobj->GetSummaryAsCString(m_options.m_varformat_language);
+ if (sum_cstr)
+ summary.assign(sum_cstr);
}
}
}
@@ -403,7 +414,9 @@ bool ValueObjectPrinter::PrintValueAndSummaryIfNeeded(bool &value_printed,
// this thing is nil (but show the value if the user passes a format
// explicitly)
TypeSummaryImpl *entry = GetSummaryFormatter();
- if (!IsNil() && !IsUninitialized() && !m_value.empty() &&
+ const bool has_nil_or_uninitialized_summary =
+ (IsNil() || IsUninitialized()) && !m_summary.empty();
+ if (!has_nil_or_uninitialized_summary && !m_value.empty() &&
(entry == nullptr ||
(entry->DoesPrintValue(m_valobj) ||
m_options.m_format != eFormatDefault) ||