Skip to content

[upstreaming] Backport D69710 and revert downstream changes to {Clang}ExpressionParser #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions lldb/include/lldb/Expression/ExpressionParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,6 @@ class ExpressionParser {
virtual bool Complete(CompletionRequest &request, unsigned line, unsigned pos,
unsigned typed_pos) = 0;

/// Parse a single expression and convert it to IR using Clang. Don't wrap
/// the expression in anything at all.
///
/// \param[in] diagnostic_manager
/// The diagnostic manager in which to store the errors and warnings.
///
/// \return
/// The number of errors encountered during parsing. 0 means
/// success.
virtual unsigned Parse(DiagnosticManager &diagnostic_manager,
uint32_t first_line = 0,
uint32_t last_line = UINT32_MAX) = 0;

/// Try to use the FixIts in the diagnostic_manager to rewrite the
/// expression. If successful, the rewritten expression is stored in the
/// diagnostic_manager, get it out with GetFixedExpression.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -859,12 +859,7 @@ bool ClangExpressionParser::Complete(CompletionRequest &request, unsigned line,
return true;
}

// Swift only
// Extra arguments are only used in Swift. We should get rid of them
// to avoid clashes when merging from upstream.
// End Swift only
unsigned ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
uint32_t first_line, uint32_t last_line) {
unsigned ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager) {
return ParseInternal(diagnostic_manager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ class ClangExpressionParser : public ExpressionParser {
/// \return
/// The number of errors encountered during parsing. 0 means
/// success.
//------------------------------------------------------------------
unsigned Parse(DiagnosticManager &diagnostic_manager, uint32_t first_line = 0,
uint32_t last_line = UINT32_MAX) override;
unsigned Parse(DiagnosticManager &diagnostic_manager);

bool RewriteExpression(DiagnosticManager &diagnostic_manager) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ ClangFunctionCaller::CompileFunction(lldb::ThreadSP thread_to_use_sp,
lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
if (jit_process_sp) {
const bool generate_debug_info = true;
m_parser.reset(new ClangExpressionParser(jit_process_sp.get(), *this,
generate_debug_info));

num_errors = m_parser->Parse(diagnostic_manager);
auto *clang_parser = new ClangExpressionParser(jit_process_sp.get(), *this,
generate_debug_info);
num_errors = clang_parser->Parse(diagnostic_manager);
m_parser.reset(clang_parser);
} else {
diagnostic_manager.PutString(eDiagnosticSeverityError,
"no process - unable to inject function");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class SwiftExpressionParser : public ExpressionParser {
/// success.
//------------------------------------------------------------------
unsigned Parse(DiagnosticManager &diagnostic_manager, uint32_t first_line = 0,
uint32_t last_line = UINT32_MAX) override;
uint32_t last_line = UINT32_MAX);

//------------------------------------------------------------------
/// Ready an already-parsed expression for execution, possibly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,11 @@ bool SwiftUserExpression::Parse(DiagnosticManager &diagnostic_manager,
exe_scope = exe_ctx.GetTargetPtr();
} while (0);

m_parser =
std::make_unique<SwiftExpressionParser>(exe_scope, *this, m_options);

unsigned error_code = m_parser->Parse(
auto *swift_parser = new SwiftExpressionParser(exe_scope, *this, m_options);
unsigned error_code = swift_parser->Parse(
diagnostic_manager, first_body_line,
first_body_line + source_code->GetNumBodyLines());
m_parser.reset(swift_parser);

if (error_code == 2) {
m_fixed_text = m_expr_text;
Expand Down