Skip to content

Commit

Permalink
[lldb][NFC] Move some ctors and tors to cpp files
Browse files Browse the repository at this point in the history
This prevents undefined vtable errors when linking these libraries from out-of-tree. I'm facing this issue as I work on my new language plugin.
  • Loading branch information
walter-erquinigo committed Sep 22, 2023
1 parent 8b2290d commit 0f7b275
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
7 changes: 3 additions & 4 deletions lldb/include/lldb/Core/UserSettingsController.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ namespace lldb_private {

class Properties {
public:
Properties() = default;
Properties();

Properties(const lldb::OptionValuePropertiesSP &collection_sp)
: m_collection_sp(collection_sp) {}
Properties(const lldb::OptionValuePropertiesSP &collection_sp);

virtual ~Properties() = default;
virtual ~Properties();

virtual lldb::OptionValuePropertiesSP GetValueProperties() const {
// This function is virtual in case subclasses want to lazily implement
Expand Down
22 changes: 6 additions & 16 deletions lldb/include/lldb/Symbol/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ using CallSiteParameterArray = llvm::SmallVector<CallSiteParameter, 0>;
class CallEdge {
public:
enum class AddrType : uint8_t { Call, AfterCall };
virtual ~CallEdge() = default;
~CallEdge();

/// Get the callee's definition.
///
Expand Down Expand Up @@ -305,10 +305,7 @@ class CallEdge {

protected:
CallEdge(AddrType caller_address_type, lldb::addr_t caller_address,
bool is_tail_call, CallSiteParameterArray &&parameters)
: caller_address(caller_address),
caller_address_type(caller_address_type), is_tail_call(is_tail_call),
parameters(std::move(parameters)) {}
bool is_tail_call, CallSiteParameterArray &&parameters);

/// Helper that finds the load address of \p unresolved_pc, a file address
/// which refers to an instruction within \p caller.
Expand Down Expand Up @@ -339,11 +336,7 @@ class DirectCallEdge : public CallEdge {
/// return PC within the calling function to identify a specific call site.
DirectCallEdge(const char *symbol_name, AddrType caller_address_type,
lldb::addr_t caller_address, bool is_tail_call,
CallSiteParameterArray &&parameters)
: CallEdge(caller_address_type, caller_address, is_tail_call,
std::move(parameters)) {
lazy_callee.symbol_name = symbol_name;
}
CallSiteParameterArray &&parameters);

Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override;

Expand All @@ -370,12 +363,9 @@ class IndirectCallEdge : public CallEdge {
public:
/// Construct a call edge using a DWARFExpression to identify the callee, and
/// a return PC within the calling function to identify a specific call site.
IndirectCallEdge(DWARFExpressionList call_target, AddrType caller_address_type,
lldb::addr_t caller_address, bool is_tail_call,
CallSiteParameterArray &&parameters)
: CallEdge(caller_address_type, caller_address, is_tail_call,
std::move(parameters)),
call_target(std::move(call_target)) {}
IndirectCallEdge(DWARFExpressionList call_target,
AddrType caller_address_type, lldb::addr_t caller_address,
bool is_tail_call, CallSiteParameterArray &&parameters);

Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override;

Expand Down
7 changes: 7 additions & 0 deletions lldb/source/Core/UserSettingsController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ class Property;
using namespace lldb;
using namespace lldb_private;

Properties::Properties() = default;

Properties::Properties(const lldb::OptionValuePropertiesSP &collection_sp)
: m_collection_sp(collection_sp) {}

Properties::~Properties() = default;

lldb::OptionValueSP
Properties::GetPropertyValue(const ExecutionContext *exe_ctx,
llvm::StringRef path, Status &error) const {
Expand Down
25 changes: 25 additions & 0 deletions lldb/source/Symbol/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ size_t InlineFunctionInfo::MemorySize() const {
/// @name Call site related structures
/// @{

CallEdge::~CallEdge() = default;

CallEdge::CallEdge(AddrType caller_address_type, lldb::addr_t caller_address,
bool is_tail_call, CallSiteParameterArray &&parameters)
: caller_address(caller_address), caller_address_type(caller_address_type),
is_tail_call(is_tail_call), parameters(std::move(parameters)) {}

lldb::addr_t CallEdge::GetLoadAddress(lldb::addr_t unresolved_pc,
Function &caller, Target &target) {
Log *log = GetLog(LLDBLog::Step);
Expand Down Expand Up @@ -185,12 +192,30 @@ void DirectCallEdge::ParseSymbolFileAndResolve(ModuleList &images) {
resolved = true;
}

DirectCallEdge::DirectCallEdge(const char *symbol_name,
AddrType caller_address_type,
lldb::addr_t caller_address, bool is_tail_call,
CallSiteParameterArray &&parameters)
: CallEdge(caller_address_type, caller_address, is_tail_call,
std::move(parameters)) {
lazy_callee.symbol_name = symbol_name;
}

Function *DirectCallEdge::GetCallee(ModuleList &images, ExecutionContext &) {
ParseSymbolFileAndResolve(images);
assert(resolved && "Did not resolve lazy callee");
return lazy_callee.def;
}

IndirectCallEdge::IndirectCallEdge(DWARFExpressionList call_target,
AddrType caller_address_type,
lldb::addr_t caller_address,
bool is_tail_call,
CallSiteParameterArray &&parameters)
: CallEdge(caller_address_type, caller_address, is_tail_call,
std::move(parameters)),
call_target(std::move(call_target)) {}

Function *IndirectCallEdge::GetCallee(ModuleList &images,
ExecutionContext &exe_ctx) {
Log *log = GetLog(LLDBLog::Step);
Expand Down

0 comments on commit 0f7b275

Please sign in to comment.