diff options
author | Alex Langford <apl@fb.com> | 2019-07-10 20:41:36 +0000 |
---|---|---|
committer | Alex Langford <apl@fb.com> | 2019-07-10 20:41:36 +0000 |
commit | 2fcf824a6c67312f496e99a28432b93e42c55666 (patch) | |
tree | fb33f19b573aae87fdeb48f6ed3a5b04a378470d /source/Expression/IRDynamicChecks.cpp | |
parent | d7ec54234d7d642611d063b18918eaaeaf851b9b (diff) |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@365696 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'source/Expression/IRDynamicChecks.cpp')
-rw-r--r-- | source/Expression/IRDynamicChecks.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/source/Expression/IRDynamicChecks.cpp b/source/Expression/IRDynamicChecks.cpp index f66dec2e7..2e7b76b32 100644 --- a/source/Expression/IRDynamicChecks.cpp +++ b/source/Expression/IRDynamicChecks.cpp @@ -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::Module &M) { } 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::Module &M) { } 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; |