LLDB mainline
ClangUtilityFunction.h
Go to the documentation of this file.
1//===-- ClangUtilityFunction.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
9#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGUTILITYFUNCTION_H
10#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGUTILITYFUNCTION_H
11
12#include <map>
13#include <string>
14#include <vector>
15
17
19#include "lldb/lldb-forward.h"
20#include "lldb/lldb-private.h"
21
22namespace lldb_private {
23
24/// \class ClangUtilityFunction ClangUtilityFunction.h
25/// "lldb/Expression/ClangUtilityFunction.h" Encapsulates a single expression
26/// for use with Clang
27///
28/// LLDB uses expressions for various purposes, notably to call functions
29/// and as a backend for the expr command. ClangUtilityFunction encapsulates
30/// a self-contained function meant to be used from other code. Utility
31/// functions can perform error-checking for ClangUserExpressions, or can
32/// simply provide a way to push a function into the target for the debugger
33/// to call later on.
35 // LLVM RTTI support
36 static char ID;
37
38public:
39 bool isA(const void *ClassID) const override {
40 return ClassID == &ID || UtilityFunction::isA(ClassID);
41 }
42 static bool classof(const Expression *obj) { return obj->isA(&ID); }
43
44 /// Constructor
45 ///
46 /// \param[in] text
47 /// The text of the function. Must be a full translation unit.
48 ///
49 /// \param[in] name
50 /// The name of the function, as used in the text.
51 ///
52 /// \param[in] enable_debugging
53 /// Enable debugging of this function.
54 ClangUtilityFunction(ExecutionContextScope &exe_scope, std::string text,
55 std::string name, bool enable_debugging);
56
58
61 }
62
64
66
67 void ResetDeclMap(ExecutionContext &exe_ctx, bool keep_result_in_memory) {
68 m_type_system_helper.ResetDeclMap(exe_ctx, keep_result_in_memory);
69 }
70
71 bool Install(DiagnosticManager &diagnostic_manager,
72 ExecutionContext &exe_ctx) override;
73
74private:
76 : public llvm::RTTIExtends<ClangUtilityFunctionHelper,
77 ClangExpressionHelper> {
78 public:
79 // LLVM RTTI support
80 static char ID;
81
82 /// Return the object that the parser should use when resolving external
83 /// values. May be NULL if everything should be self-contained.
85 return m_expr_decl_map_up.get();
86 }
87
88 void ResetDeclMap() { m_expr_decl_map_up.reset(); }
89
90 void ResetDeclMap(ExecutionContext &exe_ctx, bool keep_result_in_memory);
91
92 /// Return the object that the parser should allow to access ASTs. May be
93 /// nullptr if the ASTs do not need to be transformed.
94 ///
95 /// \param[in] passthrough
96 /// The ASTConsumer that the returned transformer should send
97 /// the ASTs to after transformation.
98 clang::ASTConsumer *
99 ASTTransformer(clang::ASTConsumer *passthrough) override {
100 return nullptr;
101 }
102
103 private:
104 std::unique_ptr<ClangExpressionDeclMap> m_expr_decl_map_up;
105 };
106
107 /// The map to use when parsing and materializing the expression.
109};
110
111} // namespace lldb_private
112
113#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGUTILITYFUNCTION_H
"lldb/Expression/ClangExpressionDeclMap.h" Manages named entities that are defined in LLDB's debug in...
ClangExpressionDeclMap * DeclMap() override
Return the object that the parser should use when resolving external values.
std::unique_ptr< ClangExpressionDeclMap > m_expr_decl_map_up
clang::ASTConsumer * ASTTransformer(clang::ASTConsumer *passthrough) override
Return the object that the parser should allow to access ASTs.
"lldb/Expression/ClangUtilityFunction.h" Encapsulates a single expression for use with Clang
void ResetDeclMap(ExecutionContext &exe_ctx, bool keep_result_in_memory)
ExpressionTypeSystemHelper * GetTypeSystemHelper() override
ClangExpressionDeclMap * DeclMap()
bool isA(const void *ClassID) const override
static bool classof(const Expression *obj)
bool Install(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) override
Install the utility function into a process.
ClangUtilityFunctionHelper m_type_system_helper
The map to use when parsing and materializing the expression.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
"lldb/Expression/ExpressionTypeSystemHelper.h" A helper object that the Expression can pass to its Ex...
Encapsulates a single expression for use in lldb.
Definition: Expression.h:31
virtual bool isA(const void *ClassID) const =0
"lldb/Expression/UtilityFunction.h" Encapsulates a bit of source code that provides a function that i...
bool isA(const void *ClassID) const override
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14