[Lldb-commits] [lldb] [NFC][lldb] Implement DiagnosticManager::Consume (PR #74011)

via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 30 16:17:56 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Augusto Noronha (augusto2112)

<details>
<summary>Changes</summary>

In some situations it may be useful to have a separate DiagnosticManager instance, and then later of move the contents of that instance back to the "main" DiagnosticManager. For example, when silently retrying some operation with different parameters, depending on whether the retry succeeded or failed, LLDB may want to present a different set of diagnostics to the user (the ones generated on the first try vs the retry). Implement DiagnosticManager::Consume to allow for this use case.

---
Full diff: https://github.com/llvm/llvm-project/pull/74011.diff


1 Files Affected:

- (modified) lldb/include/lldb/Expression/DiagnosticManager.h (+9) 


``````````diff
diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h b/lldb/include/lldb/Expression/DiagnosticManager.h
index df9ba3b245f51e8..06bf1d115f15419 100644
--- a/lldb/include/lldb/Expression/DiagnosticManager.h
+++ b/lldb/include/lldb/Expression/DiagnosticManager.h
@@ -118,6 +118,15 @@ class DiagnosticManager {
       m_diagnostics.push_back(std::move(diagnostic));
   }
 
+  /// Moves over the contents of a second diagnostic manager over. Leaves other
+  /// diagnostic manager in an empty state.
+  void Consume(DiagnosticManager &&other) {
+    std::move(other.m_diagnostics.begin(), other.m_diagnostics.end(),
+              std::back_inserter(m_diagnostics));
+    m_fixed_expression = std::move(other.m_fixed_expression);
+    other.Clear();
+  }
+
   size_t Printf(DiagnosticSeverity severity, const char *format, ...)
       __attribute__((format(printf, 3, 4)));
   void PutString(DiagnosticSeverity severity, llvm::StringRef str);

``````````

</details>


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


More information about the lldb-commits mailing list