1 //===-- ClangPersistentVariables.h ------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef liblldb_ClangPersistentVariables_h_ 11 #define liblldb_ClangPersistentVariables_h_ 12 13 // C Includes 14 // C++ Includes 15 // Other libraries and framework includes 16 #include "llvm/ADT/DenseMap.h" 17 18 // Project includes 19 #include "ClangExpressionVariable.h" 20 #include "ClangModulesDeclVendor.h" 21 22 #include "lldb/Expression/ExpressionVariable.h" 23 24 namespace lldb_private 25 { 26 27 //---------------------------------------------------------------------- 28 /// @class ClangPersistentVariables ClangPersistentVariables.h "lldb/Expression/ClangPersistentVariables.h" 29 /// @brief Manages persistent values that need to be preserved between expression invocations. 30 /// 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 36 { 37 public: 38 ClangPersistentVariables(); 39 40 ~ClangPersistentVariables() override = default; 41 42 //------------------------------------------------------------------ 43 // llvm casting support 44 //------------------------------------------------------------------ 45 static bool classof(const PersistentExpressionState *pv) 46 { 47 return pv->getKind() == PersistentExpressionState::eKindClang; 48 } 49 50 lldb::ExpressionVariableSP 51 CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp) override; 52 53 lldb::ExpressionVariableSP 54 CreatePersistentVariable (ExecutionContextScope *exe_scope, 55 const ConstString &name, 56 const CompilerType& compiler_type, 57 lldb::ByteOrder byte_order, 58 uint32_t addr_byte_size) override; 59 60 //---------------------------------------------------------------------- 61 /// Return the next entry in the sequence of strings "$0", "$1", ... for 62 /// use naming persistent expression convenience variables. 63 /// 64 /// @return 65 /// A string that contains the next persistent variable name. 66 //---------------------------------------------------------------------- 67 ConstString 68 GetNextPersistentVariableName () override; 69 70 void 71 RemovePersistentVariable (lldb::ExpressionVariableSP variable) override; 72 73 lldb::addr_t 74 LookupSymbol (const ConstString &name) override { return LLDB_INVALID_ADDRESS; } 75 76 void 77 RegisterPersistentDecl (const ConstString &name, 78 clang::NamedDecl *decl); 79 80 clang::NamedDecl * 81 GetPersistentDecl (const ConstString &name); 82 83 void 84 AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module) 85 { 86 m_hand_loaded_clang_modules.push_back(module); 87 } 88 89 const ClangModulesDeclVendor::ModuleVector &GetHandLoadedClangModules() 90 { 91 return m_hand_loaded_clang_modules; 92 } 93 94 private: 95 uint32_t m_next_persistent_variable_id; ///< The counter used by GetNextResultName(). 96 97 typedef llvm::DenseMap<const char *, clang::NamedDecl *> PersistentDeclMap; 98 PersistentDeclMap m_persistent_decls; ///< Persistent entities declared by the user. 99 100 ClangModulesDeclVendor::ModuleVector m_hand_loaded_clang_modules; ///< These are Clang modules we hand-loaded; these are the highest- 101 ///< priority source for macros. 102 }; 103 104 } // namespace lldb_private 105 106 #endif // liblldb_ClangPersistentVariables_h_ 107