[Lldb-commits] [lldb] [LLDB][SBProgress] Fix bad optional in sbprogress (PR #128971)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 27 07:39:00 PST 2025


================
@@ -40,7 +40,10 @@ SBProgress::~SBProgress() = default;
 void SBProgress::Increment(uint64_t amount, const char *description) {
   LLDB_INSTRUMENT_VA(amount, description);
 
-  m_opaque_up->Increment(amount, description);
+  std::optional<std::string> description_opt;
+  if (description && description[0])
+    description_opt = description;
+  m_opaque_up->Increment(amount, description_opt);
----------------
JDevlieghere wrote:

```suggestion
  m_opaque_up->Increment(amount, std::move(description_opt));
```
We can avoid a copy by moving the optional, as `Increment` takes it by value. 

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


More information about the lldb-commits mailing list