1 //===-- DynamicCheckerFunctions.h -------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_DynamicCheckerFunctions_h_
10 #define liblldb_DynamicCheckerFunctions_h_
12 #include "lldb/lldb-types.h"
14 namespace lldb_private {
16 class DiagnosticManager;
17 class ExecutionContext;
19 /// Encapsulates dynamic check functions used by expressions.
21 /// Each of the utility functions encapsulated in this class is responsible
22 /// for validating some data that an expression is about to use. Examples
25 /// a = *b; // check that b is a valid pointer
26 /// [b init]; // check that b is a valid object to send "init" to
28 /// The class installs each checker function into the target process and makes
29 /// it available to IRDynamicChecks to use.
30 class DynamicCheckerFunctions {
32 enum DynamicCheckerFunctionsKind {
36 DynamicCheckerFunctions(DynamicCheckerFunctionsKind kind) : m_kind(kind) {}
37 virtual ~DynamicCheckerFunctions() = default;
39 /// Install the utility functions into a process. This binds the instance
40 /// of DynamicCheckerFunctions to that process.
42 /// \param[in] diagnostic_manager
43 /// A diagnostic manager to report errors to.
45 /// \param[in] exe_ctx
46 /// The execution context to install the functions into.
49 /// True on success; false on failure, or if the functions have
50 /// already been installed.
51 virtual bool Install(DiagnosticManager &diagnostic_manager,
52 ExecutionContext &exe_ctx) = 0;
53 virtual bool DoCheckersExplainStop(lldb::addr_t addr, Stream &message) = 0;
55 DynamicCheckerFunctionsKind GetKind() const { return m_kind; }
58 const DynamicCheckerFunctionsKind m_kind;
60 } // namespace lldb_private
62 #endif // liblldb_DynamicCheckerFunctions_h_