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 #include "lldb/Expression/ClangExpressionVariable.h" 14 #include "lldb/Expression/ClangModulesDeclVendor.h" 15 16 #include "llvm/ADT/DenseMap.h" 17 18 namespace lldb_private 19 { 20 21 //---------------------------------------------------------------------- 22 /// @class ClangPersistentVariables ClangPersistentVariables.h "lldb/Expression/ClangPersistentVariables.h" 23 /// @brief Manages persistent values that need to be preserved between expression invocations. 24 /// 25 /// A list of variables that can be accessed and updated by any expression. See 26 /// ClangPersistentVariable for more discussion. Also provides an increasing, 27 /// 0-based counter for naming result variables. 28 //---------------------------------------------------------------------- 29 class ClangPersistentVariables : public ClangExpressionVariableList 30 { 31 public: 32 33 //---------------------------------------------------------------------- 34 /// Constructor 35 //---------------------------------------------------------------------- 36 ClangPersistentVariables (); 37 38 lldb::ClangExpressionVariableSP 39 CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp); 40 41 lldb::ClangExpressionVariableSP 42 CreatePersistentVariable (ExecutionContextScope *exe_scope, 43 const ConstString &name, 44 const TypeFromUser& user_type, 45 lldb::ByteOrder byte_order, 46 uint32_t addr_byte_size); 47 48 //---------------------------------------------------------------------- 49 /// Return the next entry in the sequence of strings "$0", "$1", ... for 50 /// use naming persistent expression convenience variables. 51 /// 52 /// @return 53 /// A string that contains the next persistent variable name. 54 //---------------------------------------------------------------------- 55 ConstString 56 GetNextPersistentVariableName (); 57 58 void 59 RemovePersistentVariable (lldb::ClangExpressionVariableSP variable); 60 61 void 62 RegisterPersistentType (const ConstString &name, 63 clang::TypeDecl *tag_decl); 64 65 clang::TypeDecl * 66 GetPersistentType (const ConstString &name); 67 68 void AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module)69 AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module) 70 { 71 m_hand_loaded_clang_modules.push_back(module); 72 } 73 GetHandLoadedClangModules()74 const ClangModulesDeclVendor::ModuleVector &GetHandLoadedClangModules() 75 { 76 return m_hand_loaded_clang_modules; 77 } 78 79 private: 80 uint32_t m_next_persistent_variable_id; ///< The counter used by GetNextResultName(). 81 82 typedef llvm::DenseMap<const char *, clang::TypeDecl *> PersistentTypeMap; 83 PersistentTypeMap m_persistent_types; ///< The persistent types declared by the user. 84 85 ClangModulesDeclVendor::ModuleVector m_hand_loaded_clang_modules; ///< These are Clang modules we hand-loaded; these are the highest- 86 ///< priority source for macros. 87 }; 88 89 } 90 91 #endif 92