Skip to content

Commit 0309db7

Browse files
committed
[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.
1 parent b25c046 commit 0309db7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lldb/include/lldb/Expression/DiagnosticManager.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ class DiagnosticManager {
118118
m_diagnostics.push_back(std::move(diagnostic));
119119
}
120120

121+
/// Moves over the contents of a second diagnostic manager over. Leaves other
122+
/// diagnostic manager in an empty state.
123+
void Consume(DiagnosticManager &&other) {
124+
std::move(other.m_diagnostics.begin(), other.m_diagnostics.end(),
125+
std::back_inserter(m_diagnostics));
126+
m_fixed_expression = std::move(other.m_fixed_expression);
127+
other.Clear();
128+
}
129+
121130
size_t Printf(DiagnosticSeverity severity, const char *format, ...)
122131
__attribute__((format(printf, 3, 4)));
123132
void PutString(DiagnosticSeverity severity, llvm::StringRef str);

0 commit comments

Comments
 (0)