[SBAPI] Don't check IsValid in constructor

When running the test suite with the instrumentation macros, I noticed
two lldb-mi tests regressed. The issue was the copy constructor of
SBLineEntry. Without the macros the returned value would be elided, but
with the macros the copy constructor was called. The latter using ::IsValid
to determine whether the underlying opaque pointer should be set. This
is likely a remnant of when ::IsValid would only check the validity of the
smart pointer. In SBLineEntry however, it actually forwards to
LineEntry::IsValid().

So what happened here was that because of the macros the copy
constructor was called. The opaque pointer was valid but the LineEntry
didn't consider itself valid. So the copied-to object ended up default
initialized.

This patch replaces all checks for IsValid in copy (assignment)
constructors with checks for the opaque pointer itself.

Differential revision: https://reviews.llvm.org/D58946

llvm-svn: 355458
This commit is contained in:
Jonas Devlieghere
2019-03-06 00:05:55 +00:00
parent d823020bac
commit bd4bf82a48
21 changed files with 138 additions and 150 deletions

View File

@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/API/SBModuleSpec.h"
#include "Utils.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
@@ -19,12 +20,13 @@ using namespace lldb_private;
SBModuleSpec::SBModuleSpec() : m_opaque_up(new lldb_private::ModuleSpec()) {}
SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs)
: m_opaque_up(new lldb_private::ModuleSpec(*rhs.m_opaque_up)) {}
SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs) : m_opaque_up() {
m_opaque_up = clone(rhs.m_opaque_up);
}
const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) {
if (this != &rhs)
*m_opaque_up = *(rhs.m_opaque_up);
m_opaque_up = clone(rhs.m_opaque_up);
return *this;
}