diff options
| author | Sean Callanan <scallanan@apple.com> | 2011-08-23 21:20:51 +0000 |
|---|---|---|
| committer | Sean Callanan <scallanan@apple.com> | 2011-08-23 21:20:51 +0000 |
| commit | bccce81340ce87a89df0cf8eabc7389d4a563976 (patch) | |
| tree | c52c2847ba8cefcdf2227e0d9fe43812737139d9 /lldb/source/Expression/ClangUserExpression.cpp | |
| parent | fd13f6f56aa36951fdd971ea97973e8e3446a4b6 (diff) | |
| download | bcm5719-llvm-bccce81340ce87a89df0cf8eabc7389d4a563976.tar.gz bcm5719-llvm-bccce81340ce87a89df0cf8eabc7389d4a563976.zip | |
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
Diffstat (limited to 'lldb/source/Expression/ClangUserExpression.cpp')
| -rw-r--r-- | lldb/source/Expression/ClangUserExpression.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp index 9cd84894854..f0a6359eea0 100644 --- a/lldb/source/Expression/ClangUserExpression.cpp +++ b/lldb/source/Expression/ClangUserExpression.cpp @@ -53,7 +53,8 @@ ClangUserExpression::ClangUserExpression (const char *expr, m_objectivec (false), m_needs_object_ptr (false), m_const_object (false), - m_const_result () + m_const_result (), + m_target (NULL) { } @@ -64,8 +65,15 @@ ClangUserExpression::~ClangUserExpression () clang::ASTConsumer * ClangUserExpression::ASTTransformer (clang::ASTConsumer *passthrough) { + ClangASTContext *clang_ast_context = m_target->GetScratchClangASTContext(); + + if (!clang_ast_context) + return NULL; + return new ASTResultSynthesizer(passthrough, - m_desired_type); + m_desired_type, + *m_target->GetScratchClangASTContext()->getASTContext(), + m_target->GetPersistentVariables()); } void @@ -88,6 +96,8 @@ ClangUserExpression::ScanContext(ExecutionContext &exe_ctx) if (!decl_context) return; + + m_target = exe_ctx.target; if (clang::CXXMethodDecl *method_decl = llvm::dyn_cast<clang::CXXMethodDecl>(decl_context)) { @@ -718,7 +728,7 @@ ClangUserExpression::EvaluateWithError (ExecutionContext &exe_ctx, if (log) log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with no result =="); - error.SetErrorString ("Expression did not return a result"); + error.SetError(ClangUserExpression::kNoResult, lldb::eErrorTypeGeneric); } } } |

