================ @@ -123,30 +123,80 @@ void CommandReturnObject::SetError(llvm::Error error) { } } -llvm::StringRef +std::string CommandReturnObject::GetInlineDiagnosticString(unsigned indent) { - RenderDiagnosticDetails(m_diag_stream, indent, true, m_diagnostics); + StreamString diag_stream(m_colors); + RenderDiagnosticDetails(diag_stream, indent, true, m_diagnostics); // Duplex the diagnostics to the secondary stream (but not inlined). - if (auto stream_sp = m_err_stream.GetStreamAtIndex(eStreamStringIndex)) + if (auto stream_sp = m_err_stream.GetStreamAtIndex(eImmediateStreamIndex)) RenderDiagnosticDetails(*stream_sp, std::nullopt, false, m_diagnostics); - // Clear them so GetErrorData() doesn't render them again. - m_diagnostics.clear(); - return m_diag_stream.GetString(); + return diag_stream.GetString().str(); } -llvm::StringRef CommandReturnObject::GetErrorString() { - // Diagnostics haven't been fetched; render them now (not inlined). - if (!m_diagnostics.empty()) { - RenderDiagnosticDetails(GetErrorStream(), std::nullopt, false, - m_diagnostics); - m_diagnostics.clear(); - } +std::string CommandReturnObject::GetErrorString(bool with_diagnostics) { + StreamString stream(m_colors); + if (with_diagnostics) + RenderDiagnosticDetails(stream, std::nullopt, false, m_diagnostics); lldb::StreamSP stream_sp(m_err_stream.GetStreamAtIndex(eStreamStringIndex)); if (stream_sp) - return std::static_pointer_cast<StreamString>(stream_sp)->GetString(); - return llvm::StringRef(); + stream << std::static_pointer_cast<StreamString>(stream_sp)->GetString(); + return stream.GetString().str(); +} + +StructuredData::ObjectSP CommandReturnObject::GetErrorData() { + auto make_array = []() { return std::make_unique<StructuredData::Array>(); }; + auto make_bool = [](bool b) { + return std::make_unique<StructuredData::Boolean>(b); + }; + auto make_dict = []() { + return std::make_unique<StructuredData::Dictionary>(); + }; + auto make_int = [](unsigned i) { + return std::make_unique<StructuredData::Float>(i); ---------------- JDevlieghere wrote:
Should this be `StructuredData::UnsignedInteger` or `StructuredData::SignedInteger`? https://github.com/llvm/llvm-project/pull/112109 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits