blob: daee1b86c30e0762d5a6239e51fbae4fdc6ee054 [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
Sean Callanan9301ec12015-10-01 23:07:06 +000051 CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp) override;
Greg Clayton8b2fe6d2010-12-14 02:59:59 +000052
Sean Callanan9301ec12015-10-01 23:07:06 +000053 lldb::ExpressionVariableSP
Jim Ingham6035b672011-03-31 00:19:25 +000054 CreatePersistentVariable (ExecutionContextScope *exe_scope,
55 const ConstString &name,
Sean Callanan9301ec12015-10-01 23:07:06 +000056 const CompilerType& compiler_type,
Greg Clayton8b2fe6d2010-12-14 02:59:59 +000057 lldb::ByteOrder byte_order,
Sean Callanan9301ec12015-10-01 23:07:06 +000058 uint32_t addr_byte_size) override;
Greg Clayton8b2fe6d2010-12-14 02:59:59 +000059
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;
Sean Callanan7aeb7e22015-10-01 00:38:06 +000072
73 lldb::addr_t
74 LookupSymbol (const ConstString &name) override { return LLDB_INVALID_ADDRESS; }
Greg Clayton8b2fe6d2010-12-14 02:59:59 +000075
Sean Callananbccce812011-08-23 21:20:51 +000076 void
77 RegisterPersistentType (const ConstString &name,
78 clang::TypeDecl *tag_decl);
79
80 clang::TypeDecl *
81 GetPersistentType (const ConstString &name);
82
Sean Callananf0c5aeb2015-04-20 16:31:29 +000083 void
84 AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module)
85 {
86 m_hand_loaded_clang_modules.push_back(module);
87 }
88
89 const ClangModulesDeclVendor::ModuleVector &GetHandLoadedClangModules()
90 {
91 return m_hand_loaded_clang_modules;
92 }
93
Sean Callanan2235f322010-08-11 03:57:18 +000094private:
Sean Callananbccce812011-08-23 21:20:51 +000095 uint32_t m_next_persistent_variable_id; ///< The counter used by GetNextResultName().
96
97 typedef llvm::DenseMap<const char *, clang::TypeDecl *> PersistentTypeMap;
98 PersistentTypeMap m_persistent_types; ///< The persistent types declared by the user.
Sean Callananf0c5aeb2015-04-20 16:31:29 +000099
100 ClangModulesDeclVendor::ModuleVector m_hand_loaded_clang_modules; ///< These are Clang modules we hand-loaded; these are the highest-
101 ///< priority source for macros.
Sean Callanan2235f322010-08-11 03:57:18 +0000102};
103
104}
105
Johnny Chen03b5a8a2010-08-12 19:42:59 +0000106#endif