summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/ClangExpressionDeclMap.cpp
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2011-08-23 21:20:51 +0000
committerSean Callanan <scallanan@apple.com>2011-08-23 21:20:51 +0000
commitbccce81340ce87a89df0cf8eabc7389d4a563976 (patch)
treec52c2847ba8cefcdf2227e0d9fe43812737139d9 /lldb/source/Expression/ClangExpressionDeclMap.cpp
parentfd13f6f56aa36951fdd971ea97973e8e3446a4b6 (diff)
downloadbcm5719-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/ClangExpressionDeclMap.cpp')
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 08e7724d0fc..75387a9d33c 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -1945,6 +1945,42 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
return;
}
+ do
+ {
+ if (!m_parser_vars->m_exe_ctx->target)
+ break;
+
+ ClangASTContext *scratch_clang_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext();
+
+ if (!scratch_clang_ast_context)
+ break;
+
+ ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext();
+
+ if (!scratch_ast_context)
+ break;
+
+ TypeDecl *ptype_type_decl = m_parser_vars->m_persistent_vars->GetPersistentType(name);
+
+ if (!ptype_type_decl)
+ break;
+
+ Decl *parser_ptype_decl = ClangASTContext::CopyDecl(context.GetASTContext(), scratch_ast_context, ptype_type_decl);
+
+ if (!parser_ptype_decl)
+ break;
+
+ TypeDecl *parser_ptype_type_decl = dyn_cast<TypeDecl>(parser_ptype_decl);
+
+ if (!parser_ptype_type_decl)
+ break;
+
+ if (log)
+ log->Printf("Found persistent type %s", name.GetCString());
+
+ context.AddNamedDecl(parser_ptype_type_decl);
+ } while (0);
+
ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariable(name));
if (pvar_sp)
OpenPOWER on IntegriCloud