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_
15 // Other libraries and framework includes
16 #include "llvm/ADT/DenseMap.h"
19 #include "ClangExpressionVariable.h"
20 #include "ClangModulesDeclVendor.h"
22 #include "lldb/Expression/ExpressionVariable.h"
24 namespace lldb_private {
26 //----------------------------------------------------------------------
27 /// @class ClangPersistentVariables ClangPersistentVariables.h
28 /// "lldb/Expression/ClangPersistentVariables.h" Manages persistent values
29 /// that need to be preserved between expression invocations.
31 /// A list of variables that can be accessed and updated by any expression. See
32 /// ClangPersistentVariable for more discussion. Also provides an increasing,
33 /// 0-based counter for naming result variables.
34 //----------------------------------------------------------------------
35 class ClangPersistentVariables : public PersistentExpressionState {
37 ClangPersistentVariables();
39 ~ClangPersistentVariables() override = default;
41 //------------------------------------------------------------------
42 // llvm casting support
43 //------------------------------------------------------------------
44 static bool classof(const PersistentExpressionState *pv) {
45 return pv->getKind() == PersistentExpressionState::eKindClang;
48 lldb::ExpressionVariableSP
49 CreatePersistentVariable(const lldb::ValueObjectSP &valobj_sp) override;
51 lldb::ExpressionVariableSP CreatePersistentVariable(
52 ExecutionContextScope *exe_scope, const ConstString &name,
53 const CompilerType &compiler_type, lldb::ByteOrder byte_order,
54 uint32_t addr_byte_size) override;
56 void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
58 GetPersistentVariablePrefix(bool is_error) const override {
62 void RegisterPersistentDecl(const ConstString &name, clang::NamedDecl *decl);
64 clang::NamedDecl *GetPersistentDecl(const ConstString &name);
66 void AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module) {
67 m_hand_loaded_clang_modules.push_back(module);
70 const ClangModulesDeclVendor::ModuleVector &GetHandLoadedClangModules() {
71 return m_hand_loaded_clang_modules;
75 uint32_t m_next_persistent_variable_id; ///< The counter used by
76 ///GetNextResultName().
78 typedef llvm::DenseMap<const char *, clang::NamedDecl *> PersistentDeclMap;
80 m_persistent_decls; ///< Persistent entities declared by the user.
82 ClangModulesDeclVendor::ModuleVector
83 m_hand_loaded_clang_modules; ///< These are Clang modules we hand-loaded;
84 ///these are the highest-
85 ///< priority source for macros.
88 } // namespace lldb_private
90 #endif // liblldb_ClangPersistentVariables_h_