diff options
author | Jim Ingham <jingham@apple.com> | 2016-03-29 22:00:08 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2016-03-29 22:00:08 +0000 |
commit | e5ee6f04ab2a5fb162454a5b9ccc968c3c9105f1 (patch) | |
tree | c4eeebf3b9e4af20d71ce73b89b59ec550b460cc /lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp | |
parent | bd54f5bd2558c8763ce7159e6841222576707961 (diff) | |
download | bcm5719-llvm-e5ee6f04ab2a5fb162454a5b9ccc968c3c9105f1.tar.gz bcm5719-llvm-e5ee6f04ab2a5fb162454a5b9ccc968c3c9105f1.zip |
Figure out what the fixed expression is, and print it. Added another target setting to
quietly apply fixits for those who really trust clang's fixits.
Also, moved the retry into ClangUserExpression::Evaluate, where I can make a whole new ClangUserExpression
to do the work. Reusing any of the parts of a UserExpression in situ isn't supported at present.
<rdar://problem/25351938>
llvm-svn: 264793
Diffstat (limited to 'lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp')
-rw-r--r-- | lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp index 6da103e870a..50669bd4e3c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -399,6 +399,8 @@ ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, ExecutionConte } } + lldb::LanguageType lang_type = lldb::eLanguageTypeUnknown; + if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel) { m_transformed_text = m_expr_text; @@ -408,8 +410,6 @@ ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, ExecutionConte std::unique_ptr<ExpressionSourceCode> source_code( ExpressionSourceCode::CreateWrapped(prefix.c_str(), m_expr_text.c_str())); - lldb::LanguageType lang_type; - if (m_in_cplusplus_method) lang_type = lldb::eLanguageTypeC_plus_plus; else if (m_in_objectivec_method) @@ -491,37 +491,25 @@ ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, ExecutionConte // We use a shared pointer here so we can use the original parser - if it succeeds // or the rewrite parser we might make if it fails. But the parser_sp will never be empty. - std::shared_ptr<ClangExpressionParser> parser_sp(new ClangExpressionParser(exe_scope, *this, generate_debug_info)); + ClangExpressionParser parser(exe_scope, *this, generate_debug_info); - unsigned num_errors = parser_sp->Parse(diagnostic_manager); + unsigned num_errors = parser.Parse(diagnostic_manager); - // Check here for FixItHints. If there are any try fixing the source and re-parsing... - if (num_errors && diagnostic_manager.HasFixIts() && diagnostic_manager.ShouldAutoApplyFixIts()) + // Check here for FixItHints. If there are any try to apply the fixits and set the fixed text in m_fixed_text + // before returning an error. + if (num_errors) { - if (parser_sp->RewriteExpression(diagnostic_manager)) + if (diagnostic_manager.HasFixIts()) { - std::string backup_source = std::move(m_transformed_text); - m_transformed_text = diagnostic_manager.GetFixedExpression(); - // Make a new diagnostic manager and parser, and try again with the rewritten expression: - // FIXME: It would be nice to reuse the parser we have but that doesn't seem to be possible. - DiagnosticManager rewrite_manager; - std::shared_ptr<ClangExpressionParser> rewrite_parser_sp(new ClangExpressionParser(exe_scope, *this, generate_debug_info)); - unsigned rewrite_errors = rewrite_parser_sp->Parse(rewrite_manager); - if (rewrite_errors == 0) - { - diagnostic_manager.Clear(); - parser_sp = rewrite_parser_sp; - num_errors = 0; - } - else + if (parser.RewriteExpression(diagnostic_manager)) { - m_transformed_text = std::move(backup_source); + size_t fixed_start; + size_t fixed_end; + const std::string &fixed_expression = diagnostic_manager.GetFixedExpression(); + if (ExpressionSourceCode::GetOriginalBodyBounds(fixed_expression, lang_type, fixed_start, fixed_end)) + m_fixed_text = fixed_expression.substr(fixed_start, fixed_end - fixed_start); } } - } - - if (num_errors) - { diagnostic_manager.Printf(eDiagnosticSeverityError, "%u error%s parsing expression", num_errors, num_errors == 1 ? "" : "s"); @@ -535,12 +523,12 @@ ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, ExecutionConte // { - Error jit_error = parser_sp->PrepareForExecution(m_jit_start_addr, - m_jit_end_addr, - m_execution_unit_sp, - exe_ctx, - m_can_interpret, - execution_policy); + Error jit_error = parser.PrepareForExecution(m_jit_start_addr, + m_jit_end_addr, + m_execution_unit_sp, + exe_ctx, + m_can_interpret, + execution_policy); if (!jit_error.Success()) { @@ -555,7 +543,7 @@ ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, ExecutionConte if (exe_ctx.GetProcessPtr() && execution_policy == eExecutionPolicyTopLevel) { - Error static_init_error = parser_sp->RunStaticInitializers(m_execution_unit_sp, exe_ctx); + Error static_init_error = parser.RunStaticInitializers(m_execution_unit_sp, exe_ctx); if (!static_init_error.Success()) { |