ClangPersistentVariables.h revision 341825
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 24namespace lldb_private { 25 26//---------------------------------------------------------------------- 27/// @class ClangPersistentVariables ClangPersistentVariables.h 28/// "lldb/Expression/ClangPersistentVariables.h" Manages persistent values 29/// 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//---------------------------------------------------------------------- 35class ClangPersistentVariables : public PersistentExpressionState { 36public: 37 ClangPersistentVariables(); 38 39 ~ClangPersistentVariables() override = default; 40 41 //------------------------------------------------------------------ 42 // llvm casting support 43 //------------------------------------------------------------------ 44 static bool classof(const PersistentExpressionState *pv) { 45 return pv->getKind() == PersistentExpressionState::eKindClang; 46 } 47 48 lldb::ExpressionVariableSP 49 CreatePersistentVariable(const lldb::ValueObjectSP &valobj_sp) override; 50 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; 55 56 void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override; 57 llvm::StringRef 58 GetPersistentVariablePrefix(bool is_error) const override { 59 return "$"; 60 } 61 62 void RegisterPersistentDecl(const ConstString &name, clang::NamedDecl *decl); 63 64 clang::NamedDecl *GetPersistentDecl(const ConstString &name); 65 66 void AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module) { 67 m_hand_loaded_clang_modules.push_back(module); 68 } 69 70 const ClangModulesDeclVendor::ModuleVector &GetHandLoadedClangModules() { 71 return m_hand_loaded_clang_modules; 72 } 73 74private: 75 uint32_t m_next_persistent_variable_id; ///< The counter used by 76 ///GetNextResultName(). 77 78 typedef llvm::DenseMap<const char *, clang::NamedDecl *> PersistentDeclMap; 79 PersistentDeclMap 80 m_persistent_decls; ///< Persistent entities declared by the user. 81 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. 86}; 87 88} // namespace lldb_private 89 90#endif // liblldb_ClangPersistentVariables_h_ 91