Skip to content

Commit

Permalink
[lldb/API] Fix bogus copy assignment operator
Browse files Browse the repository at this point in the history
The copy assignment operator is supposed to return the class and not
void. Fix the methods and the reproducer instrumentation macros.
  • Loading branch information
JDevlieghere committed Jan 29, 2020
1 parent a9bc7b8 commit ede5cd9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lldb/include/lldb/API/SBLaunchInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LLDB_API SBLaunchInfo {

SBLaunchInfo(const SBLaunchInfo &rhs);

void operator=(const SBLaunchInfo &rhs);
SBLaunchInfo &operator=(const SBLaunchInfo &rhs);

lldb::pid_t GetProcessID();

Expand Down
6 changes: 4 additions & 2 deletions lldb/include/lldb/API/SBPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LLDB_API SBPlatformConnectOptions {

~SBPlatformConnectOptions();

void operator=(const SBPlatformConnectOptions &rhs);
SBPlatformConnectOptions &operator=(const SBPlatformConnectOptions &rhs);

const char *GetURL();

Expand All @@ -55,6 +55,8 @@ class LLDB_API SBPlatformShellCommand {

SBPlatformShellCommand(const SBPlatformShellCommand &rhs);

SBPlatformShellCommand &operator=(const SBPlatformShellCommand &rhs);

~SBPlatformShellCommand();

void Clear();
Expand Down Expand Up @@ -91,7 +93,7 @@ class LLDB_API SBPlatform {

SBPlatform(const SBPlatform &rhs);

void operator=(const SBPlatform &rhs);
SBPlatform &operator=(const SBPlatform &rhs);

~SBPlatform();

Expand Down
9 changes: 5 additions & 4 deletions lldb/source/API/SBLaunchInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down Expand Up @@ -336,7 +337,7 @@ template <>
void RegisterMethods<SBLaunchInfo>(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, ());
Expand Down
33 changes: 26 additions & 7 deletions lldb/source/API/SBPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {}
Expand Down Expand Up @@ -637,7 +652,7 @@ void RegisterMethods<SBPlatformConnectOptions>(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, ());
Expand All @@ -658,6 +673,9 @@ void RegisterMethods<SBPlatformShellCommand>(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,
Expand All @@ -680,7 +698,8 @@ void RegisterMethods<SBPlatform>(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, ());
Expand Down

0 comments on commit ede5cd9

Please sign in to comment.