[Lldb-commits] [lldb] [lldb] Implement DiagnosticManager::Consume (PR #74011)
Augusto Noronha via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 30 16:17:26 PST 2023
https://github.com/augusto2112 created https://github.com/llvm/llvm-project/pull/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.
>From 7fdc9832d3a0c9024d867f8cdc35706d0a8b643e Mon Sep 17 00:00:00 2001
From: Augusto Noronha <augusto2112 at me.com>
Date: Wed, 29 Nov 2023 17:30:12 -0800
Subject: [PATCH] [NFC][lldb] Implement DiagnosticManager::Consume
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.
---
lldb/include/lldb/Expression/DiagnosticManager.h | 9 +++++++++
1 file changed, 9 insertions(+)
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);
More information about the lldb-commits
mailing list