diff options
author | Sean Callanan <scallanan@apple.com> | 2016-03-28 21:20:05 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2016-03-28 21:20:05 +0000 |
commit | 863fab69a295ac3759d2c937227ae6086baed3a5 (patch) | |
tree | b4bfa580f3b95ff7b309a78bd3ee6b8575252b7e /lldb/source/Commands/CommandObjectExpression.cpp | |
parent | 7092de4cd2b3c4c209544ee631f36c64b52caf84 (diff) | |
download | bcm5719-llvm-863fab69a295ac3759d2c937227ae6086baed3a5.tar.gz bcm5719-llvm-863fab69a295ac3759d2c937227ae6086baed3a5.zip |
Expose top-level Clang expressions via the command line and the API.
Top-level Clang expressions are expressions that act as new translation units,
and define their own symbols. They do not have function wrappers like regular
expressions do, and declarations are persistent regardless of use of the dollar
sign in identifiers. Names defined by these are given priority over all other
symbol lookups.
This patch adds a new expression option, '-p' or '--top-level,' which controls
whether the expression is treated this way. It also adds a flag controlling
this to SBExpressionOptions so that this API is usable externally. It also adds
a test that validates that this works. (The test requires a fix to the Clang
AST importer which I will be committing shortly.)
<rdar://problem/22864976>
llvm-svn: 264662
Diffstat (limited to 'lldb/source/Commands/CommandObjectExpression.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index fa2be2c9efb..3f550883b29 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -63,6 +63,7 @@ CommandObjectExpression::CommandOptions::g_option_table[] = { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage, "Specifies the Language to use when parsing the expression. If not set the target.language setting is used." }, { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "apply-fixits", 'X', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage, "If true, simple FixIt hints will be automatically applied to the expression." }, { LLDB_OPT_SET_1, false, "description-verbosity", 'v', OptionParser::eOptionalArgument, nullptr, g_description_verbosity_type, 0, eArgTypeDescriptionVerbosity, "How verbose should the output of this expression be, if the object description is asked for."}, + { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "top-level", 'p', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Interpret the expression as top-level definitions rather than code to be immediately executed."} }; uint32_t @@ -149,6 +150,10 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int unwind_on_error = false; ignore_breakpoints = false; break; + + case 'p': + top_level = true; + break; case 'X': { @@ -191,6 +196,7 @@ CommandObjectExpression::CommandOptions::OptionParsingStarting (CommandInterpret language = eLanguageTypeUnknown; m_verbosity = eLanguageRuntimeDescriptionDisplayVerbosityCompact; auto_apply_fixits = eLazyBoolCalculate; + top_level = false; } const OptionDefinition* @@ -315,6 +321,9 @@ CommandObjectExpression::EvaluateExpression(const char *expr, auto_apply_fixits = m_command_options.auto_apply_fixits == eLazyBoolYes ? true : false; options.SetAutoApplyFixIts(auto_apply_fixits); + + if (m_command_options.top_level) + options.SetExecutionPolicy(eExecutionPolicyTopLevel); // If there is any chance we are going to stop and want to see // what went wrong with our expression, we should generate debug info |