From: Med Ismail Bennani Date: Sat, 15 Apr 2023 00:09:37 +0000 (-0700) Subject: [lldb/API] Add convenience constructor for SBError (NFC) X-Git-Tag: upstream/17.0.6~10436 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af1fea818391f20d585414493adb3fcdc70b4756;p=platform%2Fupstream%2Fllvm.git [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 --- 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);