[Lldb-commits] [lldb] Convert ValueObject::Dump() to return llvm::Error() (NFCish) (PR #95857)

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 18 14:36:21 PDT 2024


================
@@ -461,34 +468,34 @@ bool ValueObjectPrinter::PrintValueAndSummaryIfNeeded(bool &value_printed,
   return !error_printed;
 }
 
-bool ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed,
-                                                        bool summary_printed) {
+llvm::Error
+ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed,
+                                                   bool summary_printed) {
   if (ShouldPrintValueObject()) {
     // let's avoid the overly verbose no description error for a nil thing
     if (m_options.m_use_objc && !IsNil() && !IsUninitialized() &&
         (!m_options.m_pointer_as_array)) {
       if (!m_options.m_hide_value || ShouldShowName())
-        m_stream->Printf(" ");
-      const char *object_desc = nullptr;
-      if (value_printed || summary_printed)
-        object_desc = GetMostSpecializedValue().GetObjectDescription();
-      else
-        object_desc = GetDescriptionForDisplay();
-      if (object_desc && *object_desc) {
+        *m_stream << ' ';
+      llvm::Expected<std::string> object_desc =
+          (value_printed || summary_printed)
+              ? GetMostSpecializedValue().GetObjectDescription()
+              : GetDescriptionForDisplay();
+      if (!object_desc) {
+        if (!value_printed && !summary_printed)
+          return object_desc.takeError();
+        *m_stream << "warning: no object description available\n";
+        llvm::consumeError(object_desc.takeError());
----------------
adrian-prantl wrote:

The error will in practice be `could not evaluate print object function: expression interrupted`.
If we knew what the command was, this would be where we'd want to say they should use `p` instead of `po`, but we don't have enough information about this here. I'll add a comment about this.

https://github.com/llvm/llvm-project/pull/95857


More information about the lldb-commits mailing list