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

via lldb-commits lldb-commits at lists.llvm.org
Tue Dec 5 12:26:15 PST 2023


Author: Augusto Noronha
Date: 2023-12-05T12:26:10-08:00
New Revision: 901bc5129d1a1e8ad47801343d48dcd9e01ad386

URL: https://github.com/llvm/llvm-project/commit/901bc5129d1a1e8ad47801343d48dcd9e01ad386
DIFF: https://github.com/llvm/llvm-project/commit/901bc5129d1a1e8ad47801343d48dcd9e01ad386.diff

LOG: [NFC][lldb] Implement DiagnosticManager::Consume (#74011)

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.

Added: 
    

Modified: 
    lldb/include/lldb/Expression/DiagnosticManager.h

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Expression/DiagnosticManager.h b/lldb/include/lldb/Expression/DiagnosticManager.h
index df9ba3b245f51..06bf1d115f154 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);


        


More information about the lldb-commits mailing list