[Lldb-commits] [lldb] af1fea8 - [lldb/API] Add convenience constructor for SBError (NFC)

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 25 15:04:26 PDT 2023


Author: Med Ismail Bennani
Date: 2023-04-25T15:02:34-07:00
New Revision: af1fea818391f20d585414493adb3fcdc70b4756

URL: https://github.com/llvm/llvm-project/commit/af1fea818391f20d585414493adb3fcdc70b4756
DIFF: https://github.com/llvm/llvm-project/commit/af1fea818391f20d585414493adb3fcdc70b4756.diff

LOG: [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 <medismail.bennani at gmail.com>

Added: 
    

Modified: 
    lldb/include/lldb/API/SBError.h
    lldb/source/API/SBError.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index 16300bd93f69d..f6d5b748c56db 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -23,6 +23,8 @@ class LLDB_API SBError {
 
   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 1a034154955d8..2eb9e927514ac 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);


        


More information about the lldb-commits mailing list