blob: 828badb956411765459ed9244f4ec1941c96801f [file] [log] [blame]
Sean Callanan2235f322010-08-11 03:57:18 +00001//===-- 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
Sean Callanan4dbb2712015-09-25 20:35:58 +000013#include "ClangExpressionVariable.h"
14#include "ClangModulesDeclVendor.h"
Sean Callananf0c5aeb2015-04-20 16:31:29 +000015
Sean Callananbccce812011-08-23 21:20:51 +000016#include "llvm/ADT/DenseMap.h"
Sean Callanan2235f322010-08-11 03:57:18 +000017
18namespace lldb_private
19{
Sean Callananbccce812011-08-23 21:20:51 +000020
Sean Callananb3cecb42010-08-16 22:14:59 +000021//----------------------------------------------------------------------
Sean Callananb3cecb42010-08-16 22:14:59 +000022/// @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//----------------------------------------------------------------------
Sean Callananbc8ac342015-09-04 20:49:51 +000029class ClangPersistentVariables : public ExpressionVariableList
Sean Callanan2235f322010-08-11 03:57:18 +000030{
31public:
Sean Callanand1e5b432010-08-12 01:56:52 +000032
Sean Callananb3cecb42010-08-16 22:14:59 +000033 //----------------------------------------------------------------------
34 /// Constructor
35 //----------------------------------------------------------------------
Sean Callanan2235f322010-08-11 03:57:18 +000036 ClangPersistentVariables ();
Sean Callanand0ef0ef2010-08-20 01:02:30 +000037
Sean Callananbc8ac342015-09-04 20:49:51 +000038 lldb::ExpressionVariableSP
Greg Clayton8b2fe6d2010-12-14 02:59:59 +000039 CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp);
40
Sean Callananbc8ac342015-09-04 20:49:51 +000041 ClangExpressionVariable *
Jim Ingham6035b672011-03-31 00:19:25 +000042 CreatePersistentVariable (ExecutionContextScope *exe_scope,
43 const ConstString &name,
Greg Clayton8b2fe6d2010-12-14 02:59:59 +000044 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 ();
Sean Callanan5b26f272012-02-04 08:49:35 +000057
58 void
Sean Callananbc8ac342015-09-04 20:49:51 +000059 RemovePersistentVariable (lldb::ExpressionVariableSP variable);
Greg Clayton8b2fe6d2010-12-14 02:59:59 +000060
Sean Callananbccce812011-08-23 21:20:51 +000061 void
62 RegisterPersistentType (const ConstString &name,
63 clang::TypeDecl *tag_decl);
64
65 clang::TypeDecl *
66 GetPersistentType (const ConstString &name);
67
Sean Callananf0c5aeb2015-04-20 16:31:29 +000068 void
69 AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module)
70 {
71 m_hand_loaded_clang_modules.push_back(module);
72 }
73
74 const ClangModulesDeclVendor::ModuleVector &GetHandLoadedClangModules()
75 {
76 return m_hand_loaded_clang_modules;
77 }
78
Sean Callanan2235f322010-08-11 03:57:18 +000079private:
Sean Callananbccce812011-08-23 21:20:51 +000080 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.
Sean Callananf0c5aeb2015-04-20 16:31:29 +000084
85 ClangModulesDeclVendor::ModuleVector m_hand_loaded_clang_modules; ///< These are Clang modules we hand-loaded; these are the highest-
86 ///< priority source for macros.
Sean Callanan2235f322010-08-11 03:57:18 +000087};
88
89}
90
Johnny Chen03b5a8a2010-08-12 19:42:59 +000091#endif