From c0a9722bd66d3452ba095d9f9ef6ab67b9965c76 Mon Sep 17 00:00:00 2001 From: Walter Erquinigo Date: Fri, 22 Sep 2023 13:33:07 -0400 Subject: [PATCH] [lldb][NFC] Move some ctors and tors to cpp files (#67165) 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. --- .../lldb/Core/UserSettingsController.h | 7 +++--- lldb/include/lldb/Symbol/Function.h | 22 +++++----------- lldb/source/Core/UserSettingsController.cpp | 7 ++++++ lldb/source/Symbol/Function.cpp | 25 +++++++++++++++++++ 4 files changed, 41 insertions(+), 20 deletions(-) diff --git a/lldb/include/lldb/Core/UserSettingsController.h b/lldb/include/lldb/Core/UserSettingsController.h index ea60467c9afe5c0..32da7e05f7040f7 100644 --- a/lldb/include/lldb/Core/UserSettingsController.h +++ b/lldb/include/lldb/Core/UserSettingsController.h @@ -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 diff --git a/lldb/include/lldb/Symbol/Function.h b/lldb/include/lldb/Symbol/Function.h index 2da13f878a7992c..0c1afd0ceb6f1f5 100644 --- a/lldb/include/lldb/Symbol/Function.h +++ b/lldb/include/lldb/Symbol/Function.h @@ -267,7 +267,7 @@ using CallSiteParameterArray = llvm::SmallVector; class CallEdge { public: enum class AddrType : uint8_t { Call, AfterCall }; - virtual ~CallEdge() = default; + ~CallEdge(); /// Get the callee's definition. /// @@ -305,10 +305,7 @@ class CallEdge { protected: CallEdge(AddrType caller_address_type, lldb::addr_t caller_address, - bool is_tail_call, CallSiteParameterArray &¶meters) - : 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 &¶meters); /// Helper that finds the load address of \p unresolved_pc, a file address /// which refers to an instruction within \p caller. @@ -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 &¶meters) - : CallEdge(caller_address_type, caller_address, is_tail_call, - std::move(parameters)) { - lazy_callee.symbol_name = symbol_name; - } + CallSiteParameterArray &¶meters); Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override; @@ -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 &¶meters) - : 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 &¶meters); Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override; diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp index f5dd926cf0500b9..72217117557ffdc 100644 --- a/lldb/source/Core/UserSettingsController.cpp +++ b/lldb/source/Core/UserSettingsController.cpp @@ -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 { diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 5ed0e66bdacbd57..c651e4573854108 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -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 &¶meters) + : 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); @@ -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 &¶meters) + : 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 &¶meters) + : 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);