Author: xiaobai Date: Wed Jul 10 13:41:36 2019 New Revision: 365696 URL: http://llvm.org/viewvc/llvm-project?rev=365696&view=rev Log: [Expression] IR Instrumenters should have a UtilityFunction
Right now, IR Instrumenters take a DynamicCheckerFunctions object which has all the UtilityFunctions used to instrument IR for expressions. However, each Instrumenter (in practice) uses exactly one UtilityFunction, so let's change the abstraction. Modified: lldb/trunk/include/lldb/Expression/IRDynamicChecks.h lldb/trunk/source/Expression/IRDynamicChecks.cpp Modified: lldb/trunk/include/lldb/Expression/IRDynamicChecks.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRDynamicChecks.h?rev=365696&r1=365695&r2=365696&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/IRDynamicChecks.h (original) +++ lldb/trunk/include/lldb/Expression/IRDynamicChecks.h Wed Jul 10 13:41:36 2019 @@ -1,5 +1,4 @@ -//===-- IRDynamicChecks.h ---------------------------------------------*- C++ -//-*-===// +//===-- IRDynamicChecks.h ---------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -68,8 +67,8 @@ public: bool DoCheckersExplainStop(lldb::addr_t addr, Stream &message); - std::unique_ptr<UtilityFunction> m_valid_pointer_check; - std::unique_ptr<UtilityFunction> m_objc_object_check; + std::shared_ptr<UtilityFunction> m_valid_pointer_check; + std::shared_ptr<UtilityFunction> m_objc_object_check; }; /// \class IRDynamicChecks IRDynamicChecks.h Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=365696&r1=365695&r2=365696&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original) +++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Wed Jul 10 13:41:36 2019 @@ -134,8 +134,9 @@ public: /// /// \param[in] module /// The module being instrumented. - Instrumenter(llvm::Module &module, DynamicCheckerFunctions &checker_functions) - : m_module(module), m_checker_functions(checker_functions), + Instrumenter(llvm::Module &module, + std::shared_ptr<UtilityFunction> checker_function) + : m_module(module), m_checker_function(checker_function), m_i8ptr_ty(nullptr), m_intptr_ty(nullptr) {} virtual ~Instrumenter() = default; @@ -296,8 +297,8 @@ protected: InstVector m_to_instrument; ///< List of instructions the inspector found llvm::Module &m_module; ///< The module which is being instrumented - DynamicCheckerFunctions - &m_checker_functions; ///< The dynamic checker functions for the process + std::shared_ptr<UtilityFunction> + m_checker_function; ///< The dynamic checker function for the process private: PointerType *m_i8ptr_ty; @@ -307,8 +308,8 @@ private: class ValidPointerChecker : public Instrumenter { public: ValidPointerChecker(llvm::Module &module, - DynamicCheckerFunctions &checker_functions) - : Instrumenter(module, checker_functions), + std::shared_ptr<UtilityFunction> checker_function) + : Instrumenter(module, checker_function), m_valid_pointer_check_func(nullptr) {} ~ValidPointerChecker() override = default; @@ -322,8 +323,8 @@ protected: PrintValue(inst).c_str()); if (!m_valid_pointer_check_func) - m_valid_pointer_check_func = BuildPointerValidatorFunc( - m_checker_functions.m_valid_pointer_check->StartAddress()); + m_valid_pointer_check_func = + BuildPointerValidatorFunc(m_checker_function->StartAddress()); llvm::Value *dereferenced_ptr = nullptr; @@ -366,8 +367,8 @@ private: class ObjcObjectChecker : public Instrumenter { public: ObjcObjectChecker(llvm::Module &module, - DynamicCheckerFunctions &checker_functions) - : Instrumenter(module, checker_functions), + std::shared_ptr<UtilityFunction> checker_function) + : Instrumenter(module, checker_function), m_objc_object_check_func(nullptr) {} ~ObjcObjectChecker() override = default; @@ -391,8 +392,8 @@ protected: // InspectInstruction wouldn't have registered it if (!m_objc_object_check_func) - m_objc_object_check_func = BuildObjectCheckerFunc( - m_checker_functions.m_objc_object_check->StartAddress()); + m_objc_object_check_func = + BuildObjectCheckerFunc(m_checker_function->StartAddress()); // id objc_msgSend(id theReceiver, SEL theSelector, ...) @@ -552,7 +553,7 @@ bool IRDynamicChecks::runOnModule(llvm:: } if (m_checker_functions.m_valid_pointer_check) { - ValidPointerChecker vpc(M, m_checker_functions); + ValidPointerChecker vpc(M, m_checker_functions.m_valid_pointer_check); if (!vpc.Inspect(*function)) return false; @@ -562,7 +563,7 @@ bool IRDynamicChecks::runOnModule(llvm:: } if (m_checker_functions.m_objc_object_check) { - ObjcObjectChecker ooc(M, m_checker_functions); + ObjcObjectChecker ooc(M, m_checker_functions.m_objc_object_check); if (!ooc.Inspect(*function)) return false; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits