ClangPersistentVariables.h revision 341825
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 28341825Sdim/// "lldb/Expression/ClangPersistentVariables.h" Manages persistent values 29341825Sdim/// that need to be preserved between expression invocations. 30292932Sdim/// 31292932Sdim/// A list of variables that can be accessed and updated by any expression. See 32292932Sdim/// ClangPersistentVariable for more discussion. Also provides an increasing, 33292932Sdim/// 0-based counter for naming result variables. 34292932Sdim//---------------------------------------------------------------------- 35314564Sdimclass ClangPersistentVariables : public PersistentExpressionState { 36292932Sdimpublic: 37314564Sdim ClangPersistentVariables(); 38292932Sdim 39314564Sdim ~ClangPersistentVariables() override = default; 40292932Sdim 41314564Sdim //------------------------------------------------------------------ 42314564Sdim // llvm casting support 43314564Sdim //------------------------------------------------------------------ 44314564Sdim static bool classof(const PersistentExpressionState *pv) { 45314564Sdim return pv->getKind() == PersistentExpressionState::eKindClang; 46314564Sdim } 47292932Sdim 48314564Sdim lldb::ExpressionVariableSP 49314564Sdim CreatePersistentVariable(const lldb::ValueObjectSP &valobj_sp) override; 50292932Sdim 51314564Sdim lldb::ExpressionVariableSP CreatePersistentVariable( 52314564Sdim ExecutionContextScope *exe_scope, const ConstString &name, 53314564Sdim const CompilerType &compiler_type, lldb::ByteOrder byte_order, 54314564Sdim uint32_t addr_byte_size) override; 55292932Sdim 56314564Sdim void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override; 57341825Sdim llvm::StringRef 58341825Sdim GetPersistentVariablePrefix(bool is_error) const override { 59341825Sdim return "$"; 60341825Sdim } 61314564Sdim 62314564Sdim void RegisterPersistentDecl(const ConstString &name, clang::NamedDecl *decl); 63314564Sdim 64314564Sdim clang::NamedDecl *GetPersistentDecl(const ConstString &name); 65314564Sdim 66314564Sdim void AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module) { 67314564Sdim m_hand_loaded_clang_modules.push_back(module); 68314564Sdim } 69314564Sdim 70314564Sdim const ClangModulesDeclVendor::ModuleVector &GetHandLoadedClangModules() { 71314564Sdim return m_hand_loaded_clang_modules; 72314564Sdim } 73314564Sdim 74292932Sdimprivate: 75314564Sdim uint32_t m_next_persistent_variable_id; ///< The counter used by 76314564Sdim ///GetNextResultName(). 77314564Sdim 78314564Sdim typedef llvm::DenseMap<const char *, clang::NamedDecl *> PersistentDeclMap; 79314564Sdim PersistentDeclMap 80314564Sdim m_persistent_decls; ///< Persistent entities declared by the user. 81314564Sdim 82314564Sdim ClangModulesDeclVendor::ModuleVector 83314564Sdim m_hand_loaded_clang_modules; ///< These are Clang modules we hand-loaded; 84314564Sdim ///these are the highest- 85314564Sdim ///< priority source for macros. 86292932Sdim}; 87292932Sdim 88292932Sdim} // namespace lldb_private 89292932Sdim 90292932Sdim#endif // liblldb_ClangPersistentVariables_h_ 91