ClangPersistentVariables.h revision 314564
1292932Sdim//===-- ClangPersistentVariables.h ------------------------------*- C++ -*-===// 2292932Sdim// 3292932Sdim// The LLVM Compiler Infrastructure 4292932Sdim// 5292932Sdim// This file is distributed under the University of Illinois Open Source 6292932Sdim// License. See LICENSE.TXT for details. 7292932Sdim// 8292932Sdim//===----------------------------------------------------------------------===// 9292932Sdim 10292932Sdim#ifndef liblldb_ClangPersistentVariables_h_ 11292932Sdim#define liblldb_ClangPersistentVariables_h_ 12292932Sdim 13292932Sdim// C Includes 14292932Sdim// C++ Includes 15292932Sdim// Other libraries and framework includes 16292932Sdim#include "llvm/ADT/DenseMap.h" 17292932Sdim 18292932Sdim// Project includes 19292932Sdim#include "ClangExpressionVariable.h" 20292932Sdim#include "ClangModulesDeclVendor.h" 21292932Sdim 22292932Sdim#include "lldb/Expression/ExpressionVariable.h" 23292932Sdim 24314564Sdimnamespace lldb_private { 25314564Sdim 26292932Sdim//---------------------------------------------------------------------- 27314564Sdim/// @class ClangPersistentVariables ClangPersistentVariables.h 28314564Sdim/// "lldb/Expression/ClangPersistentVariables.h" 29314564Sdim/// @brief Manages persistent values that need to be preserved between 30314564Sdim/// expression invocations. 31292932Sdim/// 32292932Sdim/// A list of variables that can be accessed and updated by any expression. See 33292932Sdim/// ClangPersistentVariable for more discussion. Also provides an increasing, 34292932Sdim/// 0-based counter for naming result variables. 35292932Sdim//---------------------------------------------------------------------- 36314564Sdimclass ClangPersistentVariables : public PersistentExpressionState { 37292932Sdimpublic: 38314564Sdim ClangPersistentVariables(); 39292932Sdim 40314564Sdim ~ClangPersistentVariables() override = default; 41292932Sdim 42314564Sdim //------------------------------------------------------------------ 43314564Sdim // llvm casting support 44314564Sdim //------------------------------------------------------------------ 45314564Sdim static bool classof(const PersistentExpressionState *pv) { 46314564Sdim return pv->getKind() == PersistentExpressionState::eKindClang; 47314564Sdim } 48292932Sdim 49314564Sdim lldb::ExpressionVariableSP 50314564Sdim CreatePersistentVariable(const lldb::ValueObjectSP &valobj_sp) override; 51292932Sdim 52314564Sdim lldb::ExpressionVariableSP CreatePersistentVariable( 53314564Sdim ExecutionContextScope *exe_scope, const ConstString &name, 54314564Sdim const CompilerType &compiler_type, lldb::ByteOrder byte_order, 55314564Sdim uint32_t addr_byte_size) override; 56292932Sdim 57314564Sdim //---------------------------------------------------------------------- 58314564Sdim /// Return the next entry in the sequence of strings "$0", "$1", ... for 59314564Sdim /// use naming persistent expression convenience variables. 60314564Sdim /// 61314564Sdim /// @return 62314564Sdim /// A string that contains the next persistent variable name. 63314564Sdim //---------------------------------------------------------------------- 64314564Sdim ConstString GetNextPersistentVariableName() override; 65314564Sdim 66314564Sdim void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override; 67314564Sdim 68314564Sdim void RegisterPersistentDecl(const ConstString &name, clang::NamedDecl *decl); 69314564Sdim 70314564Sdim clang::NamedDecl *GetPersistentDecl(const ConstString &name); 71314564Sdim 72314564Sdim void AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module) { 73314564Sdim m_hand_loaded_clang_modules.push_back(module); 74314564Sdim } 75314564Sdim 76314564Sdim const ClangModulesDeclVendor::ModuleVector &GetHandLoadedClangModules() { 77314564Sdim return m_hand_loaded_clang_modules; 78314564Sdim } 79314564Sdim 80292932Sdimprivate: 81314564Sdim uint32_t m_next_persistent_variable_id; ///< The counter used by 82314564Sdim ///GetNextResultName(). 83314564Sdim 84314564Sdim typedef llvm::DenseMap<const char *, clang::NamedDecl *> PersistentDeclMap; 85314564Sdim PersistentDeclMap 86314564Sdim m_persistent_decls; ///< Persistent entities declared by the user. 87314564Sdim 88314564Sdim ClangModulesDeclVendor::ModuleVector 89314564Sdim m_hand_loaded_clang_modules; ///< These are Clang modules we hand-loaded; 90314564Sdim ///these are the highest- 91314564Sdim ///< priority source for macros. 92292932Sdim}; 93292932Sdim 94292932Sdim} // namespace lldb_private 95292932Sdim 96292932Sdim#endif // liblldb_ClangPersistentVariables_h_ 97