Added support for persistent types to the
expression parser. You can use a persistent
type like this:
(lldb) expr struct $foo { int a; int b; };
(lldb) struct $foo i; i.a = 2; i.b = 3; i
($foo) $0 = {
(int) a = 2
(int) b = 3
}
typedefs work similarly.
This patch affects the following files:
test/expression_command/persistent_types/*
A test case for persistent types,
in particular structs and typedefs.
ClangForward.h
Added TypeDecl, needed to declare some
functions in ASTResultSynthesizer.h
ClangPersistentVariables.[h,cpp]
Added a list of persistent types to the
persistent variable store.
ASTResultSynthesizer.[h,cpp]
Made the AST result synthesizer iterate
across TypeDecls in the expression, and
record any persistent types found. Also
made a minor documentation fix.
ClangUserExpression.[h,cpp]
Extended the user expression class to
keep the state needed to report the
persistent variable store for the target
to the AST result synthesizers.
Also introduced a new error code for
expressions that executed normally but
did not return a result.
CommandObjectExpression.cpp
Improved output for expressions (like
declarations of new persistent types) that
don't return a result. This is no longer
treated as an error.
llvm-svn: 138383
diff --git a/lldb/include/lldb/Expression/ClangPersistentVariables.h b/lldb/include/lldb/Expression/ClangPersistentVariables.h
index 21884ca..2dff7ef 100644
--- a/lldb/include/lldb/Expression/ClangPersistentVariables.h
+++ b/lldb/include/lldb/Expression/ClangPersistentVariables.h
@@ -11,10 +11,11 @@
#define liblldb_ClangPersistentVariables_h_
#include "lldb/Expression/ClangExpressionVariable.h"
+#include "llvm/ADT/DenseMap.h"
namespace lldb_private
{
-
+
//----------------------------------------------------------------------
/// @class ClangPersistentVariables ClangPersistentVariables.h "lldb/Expression/ClangPersistentVariables.h"
/// @brief Manages persistent values that need to be preserved between expression invocations.
@@ -52,8 +53,18 @@
ConstString
GetNextPersistentVariableName ();
+ void
+ RegisterPersistentType (const ConstString &name,
+ clang::TypeDecl *tag_decl);
+
+ clang::TypeDecl *
+ GetPersistentType (const ConstString &name);
+
private:
- uint32_t m_next_persistent_variable_id; ///< The counter used by GetNextResultName().
+ uint32_t m_next_persistent_variable_id; ///< The counter used by GetNextResultName().
+
+ typedef llvm::DenseMap<const char *, clang::TypeDecl *> PersistentTypeMap;
+ PersistentTypeMap m_persistent_types; ///< The persistent types declared by the user.
};
}