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 "ClangExpressionVariable.h" 14 #include "ClangModulesDeclVendor.h" 15 16 #include "lldb/Expression/ExpressionVariable.h" 17 18 #include "llvm/ADT/DenseMap.h" 19 20 namespace lldb_private 21 { 22 23 //---------------------------------------------------------------------- 24 /// @class ClangPersistentVariables ClangPersistentVariables.h "lldb/Expression/ClangPersistentVariables.h" 25 /// @brief Manages persistent values that need to be preserved between expression invocations. 26 /// 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 32 { 33 public: 34 35 //---------------------------------------------------------------------- 36 /// Constructor 37 //---------------------------------------------------------------------- 38 ClangPersistentVariables (); 39 40 ~ClangPersistentVariables () { } 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 RegisterPersistentType (const ConstString &name, 78 clang::TypeDecl *tag_decl); 79 80 clang::TypeDecl * 81 GetPersistentType (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::TypeDecl *> PersistentTypeMap; 98 PersistentTypeMap m_persistent_types; ///< The persistent types 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 } 105 106 #endif 107