blob: 4c6a19d3e5ce78881a4e8da64d948d746a00d606 [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 Callanan8f1f9a12015-09-30 19:57:57 +000016#include "lldb/Expression/ExpressionVariable.h"
17
Sean Callananbccce812011-08-23 21:20:51 +000018#include "llvm/ADT/DenseMap.h"
Sean Callanan2235f322010-08-11 03:57:18 +000019
20namespace lldb_private
21{
Sean Callananbccce812011-08-23 21:20:51 +000022
Sean Callananb3cecb42010-08-16 22:14:59 +000023//----------------------------------------------------------------------
Sean Callananb3cecb42010-08-16 22:14:59 +000024/// @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//----------------------------------------------------------------------
Sean Callanan8f1f9a12015-09-30 19:57:57 +000031class ClangPersistentVariables : public PersistentExpressionState
Sean Callanan2235f322010-08-11 03:57:18 +000032{
33public:
Sean Callanand1e5b432010-08-12 01:56:52 +000034
Sean Callananb3cecb42010-08-16 22:14:59 +000035 //----------------------------------------------------------------------
36 /// Constructor
37 //----------------------------------------------------------------------
Sean Callanan2235f322010-08-11 03:57:18 +000038 ClangPersistentVariables ();
Sean Callanan8f1f9a12015-09-30 19:57:57 +000039
40 ~ClangPersistentVariables () { }
41
42 //------------------------------------------------------------------
43 // llvm casting support
44 //------------------------------------------------------------------
45 static bool classof(const PersistentExpressionState *pv)
46 {
47 return pv->getKind() == PersistentExpressionState::eKindClang;
48 }
Sean Callanand0ef0ef2010-08-20 01:02:30 +000049
Sean Callananbc8ac342015-09-04 20:49:51 +000050 lldb::ExpressionVariableSP
Greg Clayton8b2fe6d2010-12-14 02:59:59 +000051 CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp);
52
Sean Callananbc8ac342015-09-04 20:49:51 +000053 ClangExpressionVariable *
Jim Ingham6035b672011-03-31 00:19:25 +000054 CreatePersistentVariable (ExecutionContextScope *exe_scope,
55 const ConstString &name,
Greg Clayton8b2fe6d2010-12-14 02:59:59 +000056 const TypeFromUser& user_type,
57 lldb::ByteOrder byte_order,
58 uint32_t addr_byte_size);
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
Sean Callanan8f1f9a12015-09-30 19:57:57 +000068 GetNextPersistentVariableName () override;
Sean Callanan5b26f272012-02-04 08:49:35 +000069
70 void
Sean Callanan8f1f9a12015-09-30 19:57:57 +000071 RemovePersistentVariable (lldb::ExpressionVariableSP variable) override;
Greg Clayton8b2fe6d2010-12-14 02:59:59 +000072
Sean Callananbccce812011-08-23 21:20:51 +000073 void
74 RegisterPersistentType (const ConstString &name,
75 clang::TypeDecl *tag_decl);
76
77 clang::TypeDecl *
78 GetPersistentType (const ConstString &name);
79
Sean Callananf0c5aeb2015-04-20 16:31:29 +000080 void
81 AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module)
82 {
83 m_hand_loaded_clang_modules.push_back(module);
84 }
85
86 const ClangModulesDeclVendor::ModuleVector &GetHandLoadedClangModules()
87 {
88 return m_hand_loaded_clang_modules;
89 }
90
Sean Callanan2235f322010-08-11 03:57:18 +000091private:
Sean Callananbccce812011-08-23 21:20:51 +000092 uint32_t m_next_persistent_variable_id; ///< The counter used by GetNextResultName().
93
94 typedef llvm::DenseMap<const char *, clang::TypeDecl *> PersistentTypeMap;
95 PersistentTypeMap m_persistent_types; ///< The persistent types declared by the user.
Sean Callananf0c5aeb2015-04-20 16:31:29 +000096
97 ClangModulesDeclVendor::ModuleVector m_hand_loaded_clang_modules; ///< These are Clang modules we hand-loaded; these are the highest-
98 ///< priority source for macros.
Sean Callanan2235f322010-08-11 03:57:18 +000099};
100
101}
102
Johnny Chen03b5a8a2010-08-12 19:42:59 +0000103#endif