DynamicCheckerFunctions.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //===-- DynamicCheckerFunctions.h -------------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLDB_EXPRESSION_DYNAMICCHECKERFUNCTIONS_H
  9. #define LLDB_EXPRESSION_DYNAMICCHECKERFUNCTIONS_H
  10. #include "lldb/lldb-types.h"
  11. namespace lldb_private {
  12. class DiagnosticManager;
  13. class ExecutionContext;
  14. /// Encapsulates dynamic check functions used by expressions.
  15. ///
  16. /// Each of the utility functions encapsulated in this class is responsible
  17. /// for validating some data that an expression is about to use. Examples
  18. /// are:
  19. ///
  20. /// a = *b; // check that b is a valid pointer
  21. /// [b init]; // check that b is a valid object to send "init" to
  22. ///
  23. /// The class installs each checker function into the target process and makes
  24. /// it available to IRDynamicChecks to use.
  25. class DynamicCheckerFunctions {
  26. public:
  27. enum DynamicCheckerFunctionsKind {
  28. DCF_Clang,
  29. };
  30. DynamicCheckerFunctions(DynamicCheckerFunctionsKind kind) : m_kind(kind) {}
  31. virtual ~DynamicCheckerFunctions() = default;
  32. /// Install the utility functions into a process. This binds the instance
  33. /// of DynamicCheckerFunctions to that process.
  34. ///
  35. /// \param[in] diagnostic_manager
  36. /// A diagnostic manager to report errors to.
  37. ///
  38. /// \param[in] exe_ctx
  39. /// The execution context to install the functions into.
  40. ///
  41. /// \return
  42. /// True on success; false on failure, or if the functions have
  43. /// already been installed.
  44. virtual bool Install(DiagnosticManager &diagnostic_manager,
  45. ExecutionContext &exe_ctx) = 0;
  46. virtual bool DoCheckersExplainStop(lldb::addr_t addr, Stream &message) = 0;
  47. DynamicCheckerFunctionsKind GetKind() const { return m_kind; }
  48. private:
  49. const DynamicCheckerFunctionsKind m_kind;
  50. };
  51. } // namespace lldb_private
  52. #endif // LLDB_EXPRESSION_DYNAMICCHECKERFUNCTIONS_H