1 //===-- ClangPersistentVariables.h ------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ClangPersistentVariables_h_
11 #define liblldb_ClangPersistentVariables_h_
13 #include "llvm/ADT/DenseMap.h"
15 #include "ClangExpressionVariable.h"
16 #include "ClangModulesDeclVendor.h"
18 #include "lldb/Expression/ExpressionVariable.h"
20 namespace lldb_private {
22 //----------------------------------------------------------------------
23 /// @class ClangPersistentVariables ClangPersistentVariables.h
24 /// "lldb/Expression/ClangPersistentVariables.h" Manages persistent values
25 /// that need to be preserved between expression invocations.
27 /// A list of variables that can be accessed and updated by any expression. See
28 /// ClangPersistentVariable for more discussion. Also provides an increasing,
29 /// 0-based counter for naming result variables.
30 //----------------------------------------------------------------------
31 class ClangPersistentVariables : public PersistentExpressionState {
33 ClangPersistentVariables();
35 ~ClangPersistentVariables() override = default;
37 //------------------------------------------------------------------
38 // llvm casting support
39 //------------------------------------------------------------------
40 static bool classof(const PersistentExpressionState *pv) {
41 return pv->getKind() == PersistentExpressionState::eKindClang;
44 lldb::ExpressionVariableSP
45 CreatePersistentVariable(const lldb::ValueObjectSP &valobj_sp) override;
47 lldb::ExpressionVariableSP CreatePersistentVariable(
48 ExecutionContextScope *exe_scope, const ConstString &name,
49 const CompilerType &compiler_type, lldb::ByteOrder byte_order,
50 uint32_t addr_byte_size) override;
52 void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
54 GetPersistentVariablePrefix(bool is_error) const override {
58 void RegisterPersistentDecl(const ConstString &name, clang::NamedDecl *decl);
60 clang::NamedDecl *GetPersistentDecl(const ConstString &name);
62 void AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module) {
63 m_hand_loaded_clang_modules.push_back(module);
66 const ClangModulesDeclVendor::ModuleVector &GetHandLoadedClangModules() {
67 return m_hand_loaded_clang_modules;
71 uint32_t m_next_persistent_variable_id; ///< The counter used by
72 ///GetNextResultName().
74 typedef llvm::DenseMap<const char *, clang::NamedDecl *> PersistentDeclMap;
76 m_persistent_decls; ///< Persistent entities declared by the user.
78 ClangModulesDeclVendor::ModuleVector
79 m_hand_loaded_clang_modules; ///< These are Clang modules we hand-loaded;
80 ///these are the highest-
81 ///< priority source for macros.
84 } // namespace lldb_private
86 #endif // liblldb_ClangPersistentVariables_h_