From af1fea818391f20d585414493adb3fcdc70b4756 Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Fri, 14 Apr 2023 17:09:37 -0700 Subject: [PATCH] [lldb/API] Add convenience constructor for SBError (NFC) This patch adds a new convience constructor to the SBError to initialize it with a string message to avoid having to create the object and call the `SetErrorString` method afterwards. This is very handy to report errors from lldb scripted affordances. Differential Revision: https://reviews.llvm.org/D148401 Signed-off-by: Med Ismail Bennani --- lldb/include/lldb/API/SBError.h | 2 ++ lldb/source/API/SBError.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h index 16300bd..f6d5b74 100644 --- a/lldb/include/lldb/API/SBError.h +++ b/lldb/include/lldb/API/SBError.h @@ -23,6 +23,8 @@ public: SBError(const lldb::SBError &rhs); + SBError(const char *message); + #ifndef SWIG SBError(const lldb_private::Status &error); #endif diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp index 1a034154..2eb9e92 100644 --- a/lldb/source/API/SBError.cpp +++ b/lldb/source/API/SBError.cpp @@ -25,6 +25,12 @@ SBError::SBError(const SBError &rhs) { m_opaque_up = clone(rhs.m_opaque_up); } +SBError::SBError(const char *message) { + LLDB_INSTRUMENT_VA(this, message); + + SetErrorString(message); +} + SBError::SBError(const lldb_private::Status &status) : m_opaque_up(new Status(status)) { LLDB_INSTRUMENT_VA(this, status); -- 2.7.4