[Lldb-commits] [lldb] [lldb][ValueObject][NFC] Further remove redundant parameters to ReadPointedString (PR #78029)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Sat Jan 13 04:33:17 PST 2024


https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/78029

We only ever call this function once, without relying on the defaulted `honor_array` parameter, so make it non-defaulted. Also `max_length` is always set to `0`, so remove it entirely.

This simplifies some upcoming refactoring.

>From b4d95ce7619ad43e2afc700649deac871c245cd1 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Sat, 13 Jan 2024 12:30:20 +0000
Subject: [PATCH] [lldb][ValueObject][NFC] Further remove redundant parameters
 to ReadPointedString

This simplifies some upcoming refactoring.
---
 lldb/include/lldb/Core/ValueObject.h |  2 +-
 lldb/source/Core/ValueObject.cpp     | 13 ++++++-------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h
index dec1c7b237ac27..4c0b0b2dae6cd4 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -670,7 +670,7 @@ class ValueObject {
 
   std::pair<size_t, bool>
   ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error,
-                    uint32_t max_length = 0, bool honor_array = true);
+                    bool honor_array);
 
   virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
                                 uint32_t item_count = 1);
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index a5d155d3c6675f..9208047be36668 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -813,8 +813,7 @@ static bool CopyStringDataToBufferSP(const StreamString &source,
 
 std::pair<size_t, bool>
 ValueObject::ReadPointedString(lldb::WritableDataBufferSP &buffer_sp,
-                               Status &error, uint32_t max_length,
-                               bool honor_array) {
+                               Status &error, bool honor_array) {
   bool was_capped = false;
   StreamString s;
   ExecutionContext exe_ctx(GetExecutionContextRef());
@@ -827,8 +826,7 @@ ValueObject::ReadPointedString(lldb::WritableDataBufferSP &buffer_sp,
     return {0, was_capped};
   }
 
-  if (max_length == 0)
-    max_length = target->GetMaximumSizeOfStringSummary();
+  const auto max_length = target->GetMaximumSizeOfStringSummary();
 
   size_t bytes_read = 0;
   size_t total_bytes_read = 0;
@@ -1149,9 +1147,10 @@ bool ValueObject::DumpPrintableRepresentation(
       {
         Status error;
         lldb::WritableDataBufferSP buffer_sp;
-        std::pair<size_t, bool> read_string = ReadPointedString(
-            buffer_sp, error, 0, (custom_format == eFormatVectorOfChar) ||
-                                     (custom_format == eFormatCharArray));
+        std::pair<size_t, bool> read_string =
+            ReadPointedString(buffer_sp, error,
+                              (custom_format == eFormatVectorOfChar) ||
+                                  (custom_format == eFormatCharArray));
         lldb_private::formatters::StringPrinter::
             ReadBufferAndDumpToStreamOptions options(*this);
         options.SetData(DataExtractor(



More information about the lldb-commits mailing list