https://github.com/chelcassanova created https://github.com/llvm/llvm-project/pull/79912
The `total` parameter for the constructor for Progress was changed to a std::optional in https://github.com/llvm/llvm-project/pull/77547. When initializing the `m_total` member variable for progress, it is set to 1 if the `total` parameter is std::nullopt. Other areas of the code were still checking if `m_total` was a UINT64_MAX to determine if the progress was deterministic or not, so these have been changed to check for the integer 1. The member variable `m_total` could be changed to a std::optional as well, but this means that the `ProgressEventData::GetTotal()` (which is used for the public API) would either need to return a std::optional value or it would return some specific integer to represent non-deterministic progress if `m_total` is std::nullopt. >From 1f1643617a75ec6ee7614dc4136b39f4138185e9 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova <chelsea_cassan...@apple.com> Date: Mon, 29 Jan 2024 15:29:46 -0800 Subject: [PATCH] [lldb][progress] Correctly check total for deterministic progress The `total` parameter for the constructor for Progress was changed to a std::optional in https://github.com/llvm/llvm-project/pull/77547. When initializing the `m_total` member variable for progress, it is set to 1 if the `total` parameter is std::nullopt. Other areas of the code were still checking if `m_total` was a UINT64_MAX to determine if the progress was deterministic or not, so these have been changed to check for the integer 1. The member variable `m_total` could be changed to a std::optional as well, but this means that the `ProgressEventData::GetTotal()` (which is used for the public API) would either need to return a std::optional value or it would return some specific integer to represent non-deterministic progress if `m_total` is std::nullopt. --- lldb/include/lldb/Core/DebuggerEvents.h | 2 +- lldb/source/Core/DebuggerEvents.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/include/lldb/Core/DebuggerEvents.h b/lldb/include/lldb/Core/DebuggerEvents.h index 4a27766e94e3a..2c3fcd7069d5e 100644 --- a/lldb/include/lldb/Core/DebuggerEvents.h +++ b/lldb/include/lldb/Core/DebuggerEvents.h @@ -39,7 +39,7 @@ class ProgressEventData : public EventData { GetAsStructuredData(const Event *event_ptr); uint64_t GetID() const { return m_id; } - bool IsFinite() const { return m_total != UINT64_MAX; } + bool IsFinite() const { return m_total != 1; } uint64_t GetCompleted() const { return m_completed; } uint64_t GetTotal() const { return m_total; } std::string GetMessage() const { diff --git a/lldb/source/Core/DebuggerEvents.cpp b/lldb/source/Core/DebuggerEvents.cpp index dd77fff349a64..c83bc20fba97a 100644 --- a/lldb/source/Core/DebuggerEvents.cpp +++ b/lldb/source/Core/DebuggerEvents.cpp @@ -41,7 +41,7 @@ void ProgressEventData::Dump(Stream *s) const { s->PutCString(", type = update"); // If m_total is UINT64_MAX, there is no progress to report, just "start" // and "end". If it isn't we will show the completed and total amounts. - if (m_total != UINT64_MAX) + if (m_total != 1) s->Printf(", progress = %" PRIu64 " of %" PRIu64, m_completed, m_total); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits