From ede5cd9a45bd12c0676da80472e629801faa37bf Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 28 Jan 2020 17:09:49 -0800 Subject: [PATCH] [lldb/API] Fix bogus copy assignment operator The copy assignment operator is supposed to return the class and not void. Fix the methods and the reproducer instrumentation macros. --- lldb/include/lldb/API/SBLaunchInfo.h | 2 +- lldb/include/lldb/API/SBPlatform.h | 6 ++++-- lldb/source/API/SBLaunchInfo.cpp | 9 +++++---- lldb/source/API/SBPlatform.cpp | 33 ++++++++++++++++++++++++++------- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/lldb/include/lldb/API/SBLaunchInfo.h b/lldb/include/lldb/API/SBLaunchInfo.h index eef6bc7..d78106a 100644 --- a/lldb/include/lldb/API/SBLaunchInfo.h +++ b/lldb/include/lldb/API/SBLaunchInfo.h @@ -28,7 +28,7 @@ public: SBLaunchInfo(const SBLaunchInfo &rhs); - void operator=(const SBLaunchInfo &rhs); + SBLaunchInfo &operator=(const SBLaunchInfo &rhs); lldb::pid_t GetProcessID(); diff --git a/lldb/include/lldb/API/SBPlatform.h b/lldb/include/lldb/API/SBPlatform.h index 9e3d03e..533bb4d 100644 --- a/lldb/include/lldb/API/SBPlatform.h +++ b/lldb/include/lldb/API/SBPlatform.h @@ -28,7 +28,7 @@ public: ~SBPlatformConnectOptions(); - void operator=(const SBPlatformConnectOptions &rhs); + SBPlatformConnectOptions &operator=(const SBPlatformConnectOptions &rhs); const char *GetURL(); @@ -55,6 +55,8 @@ public: SBPlatformShellCommand(const SBPlatformShellCommand &rhs); + SBPlatformShellCommand &operator=(const SBPlatformShellCommand &rhs); + ~SBPlatformShellCommand(); void Clear(); @@ -91,7 +93,7 @@ public: SBPlatform(const SBPlatform &rhs); - void operator=(const SBPlatform &rhs); + SBPlatform &operator=(const SBPlatform &rhs); ~SBPlatform(); diff --git a/lldb/source/API/SBLaunchInfo.cpp b/lldb/source/API/SBLaunchInfo.cpp index 9e71599..9e69b53 100644 --- a/lldb/source/API/SBLaunchInfo.cpp +++ b/lldb/source/API/SBLaunchInfo.cpp @@ -49,11 +49,12 @@ SBLaunchInfo::SBLaunchInfo(const SBLaunchInfo &rhs) { m_opaque_sp = rhs.m_opaque_sp; } -void SBLaunchInfo::operator=(const SBLaunchInfo &rhs) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, operator=,(const lldb::SBLaunchInfo &), - rhs); +SBLaunchInfo &SBLaunchInfo::operator=(const SBLaunchInfo &rhs) { + LLDB_RECORD_METHOD(SBLaunchInfo &, + SBLaunchInfo, operator=,(const lldb::SBLaunchInfo &), rhs); m_opaque_sp = rhs.m_opaque_sp; + return LLDB_RECORD_RESULT(*this); } SBLaunchInfo::~SBLaunchInfo() {} @@ -336,7 +337,7 @@ template <> void RegisterMethods(Registry &R) { LLDB_REGISTER_CONSTRUCTOR(SBLaunchInfo, (const char **)); LLDB_REGISTER_CONSTRUCTOR(SBLaunchInfo, (const lldb::SBLaunchInfo &)); - LLDB_REGISTER_METHOD(void, + LLDB_REGISTER_METHOD(SBLaunchInfo &, SBLaunchInfo, operator=,(const lldb::SBLaunchInfo &)); LLDB_REGISTER_METHOD(lldb::pid_t, SBLaunchInfo, GetProcessID, ()); LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetUserID, ()); diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp index 76b8515..2603ac7 100644 --- a/lldb/source/API/SBPlatform.cpp +++ b/lldb/source/API/SBPlatform.cpp @@ -80,14 +80,16 @@ SBPlatformConnectOptions::SBPlatformConnectOptions( SBPlatformConnectOptions::~SBPlatformConnectOptions() { delete m_opaque_ptr; } -void SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs) { +SBPlatformConnectOptions &SBPlatformConnectOptions:: +operator=(const SBPlatformConnectOptions &rhs) { LLDB_RECORD_METHOD( - void, + SBPlatformConnectOptions &, SBPlatformConnectOptions, operator=,( const lldb::SBPlatformConnectOptions &), rhs); *m_opaque_ptr = *rhs.m_opaque_ptr; + return LLDB_RECORD_RESULT(*this); } const char *SBPlatformConnectOptions::GetURL() { @@ -174,6 +176,18 @@ SBPlatformShellCommand::SBPlatformShellCommand( *m_opaque_ptr = *rhs.m_opaque_ptr; } +SBPlatformShellCommand &SBPlatformShellCommand:: +operator=(const SBPlatformShellCommand &rhs) { + + LLDB_RECORD_METHOD( + SBPlatformShellCommand &, + SBPlatformShellCommand, operator=,(const lldb::SBPlatformShellCommand &), + rhs); + + *m_opaque_ptr = *rhs.m_opaque_ptr; + return LLDB_RECORD_RESULT(*this); +} + SBPlatformShellCommand::~SBPlatformShellCommand() { delete m_opaque_ptr; } void SBPlatformShellCommand::Clear() { @@ -279,11 +293,12 @@ SBPlatform::SBPlatform(const SBPlatform &rhs) { m_opaque_sp = rhs.m_opaque_sp; } -void SBPlatform::operator=(const SBPlatform &rhs) { - LLDB_RECORD_METHOD(void, SBPlatform, operator=,(const lldb::SBPlatform &), - rhs); +SBPlatform &SBPlatform::operator=(const SBPlatform &rhs) { + LLDB_RECORD_METHOD(SBPlatform &, + SBPlatform, operator=,(const lldb::SBPlatform &), rhs); m_opaque_sp = rhs.m_opaque_sp; + return LLDB_RECORD_RESULT(*this); } SBPlatform::~SBPlatform() {} @@ -637,7 +652,7 @@ void RegisterMethods(Registry &R) { LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions, (const lldb::SBPlatformConnectOptions &)); LLDB_REGISTER_METHOD( - void, + SBPlatformConnectOptions &, SBPlatformConnectOptions, operator=,( const lldb::SBPlatformConnectOptions &)); LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions, GetURL, ()); @@ -658,6 +673,9 @@ void RegisterMethods(Registry &R) { LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, (const char *)); LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, (const lldb::SBPlatformShellCommand &)); + LLDB_REGISTER_METHOD( + SBPlatformShellCommand &, + SBPlatformShellCommand, operator=,(const lldb::SBPlatformShellCommand &)); LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, Clear, ()); LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetCommand, ()); LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetCommand, @@ -680,7 +698,8 @@ void RegisterMethods(Registry &R) { LLDB_REGISTER_CONSTRUCTOR(SBPlatform, ()); LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const char *)); LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const lldb::SBPlatform &)); - LLDB_REGISTER_METHOD(void, SBPlatform, operator=,(const lldb::SBPlatform &)); + LLDB_REGISTER_METHOD(SBPlatform &, + SBPlatform, operator=,(const lldb::SBPlatform &)); LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, IsValid, ()); LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, operator bool, ()); LLDB_REGISTER_METHOD(void, SBPlatform, Clear, ()); -- 2.7.4