Skip to content

Commit ce25422

Browse files
committed
[upstreaming] Backport D69710 and revert downstream changes to {Clang}ExpressionParser
1 parent 113c0ef commit ce25422

File tree

6 files changed

+10
-31
lines changed

6 files changed

+10
-31
lines changed

lldb/include/lldb/Expression/ExpressionParser.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,6 @@ class ExpressionParser {
7676
virtual bool Complete(CompletionRequest &request, unsigned line, unsigned pos,
7777
unsigned typed_pos) = 0;
7878

79-
/// Parse a single expression and convert it to IR using Clang. Don't wrap
80-
/// the expression in anything at all.
81-
///
82-
/// \param[in] diagnostic_manager
83-
/// The diagnostic manager in which to store the errors and warnings.
84-
///
85-
/// \return
86-
/// The number of errors encountered during parsing. 0 means
87-
/// success.
88-
virtual unsigned Parse(DiagnosticManager &diagnostic_manager,
89-
uint32_t first_line = 0,
90-
uint32_t last_line = UINT32_MAX) = 0;
91-
9279
/// Try to use the FixIts in the diagnostic_manager to rewrite the
9380
/// expression. If successful, the rewritten expression is stored in the
9481
/// diagnostic_manager, get it out with GetFixedExpression.

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -859,12 +859,7 @@ bool ClangExpressionParser::Complete(CompletionRequest &request, unsigned line,
859859
return true;
860860
}
861861

862-
// Swift only
863-
// Extra arguments are only used in Swift. We should get rid of them
864-
// to avoid clashes when merging from upstream.
865-
// End Swift only
866-
unsigned ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
867-
uint32_t first_line, uint32_t last_line) {
862+
unsigned ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager) {
868863
return ParseInternal(diagnostic_manager);
869864
}
870865

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ class ClangExpressionParser : public ExpressionParser {
7272
/// \return
7373
/// The number of errors encountered during parsing. 0 means
7474
/// success.
75-
//------------------------------------------------------------------
76-
unsigned Parse(DiagnosticManager &diagnostic_manager, uint32_t first_line = 0,
77-
uint32_t last_line = UINT32_MAX) override;
75+
unsigned Parse(DiagnosticManager &diagnostic_manager);
7876

7977
bool RewriteExpression(DiagnosticManager &diagnostic_manager) override;
8078

lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ ClangFunctionCaller::CompileFunction(lldb::ThreadSP thread_to_use_sp,
186186
lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
187187
if (jit_process_sp) {
188188
const bool generate_debug_info = true;
189-
m_parser.reset(new ClangExpressionParser(jit_process_sp.get(), *this,
190-
generate_debug_info));
191-
192-
num_errors = m_parser->Parse(diagnostic_manager);
189+
auto *clang_parser = new ClangExpressionParser(jit_process_sp.get(), *this,
190+
generate_debug_info);
191+
num_errors = clang_parser->Parse(diagnostic_manager);
192+
m_parser.reset(clang_parser);
193193
} else {
194194
diagnostic_manager.PutString(eDiagnosticSeverityError,
195195
"no process - unable to inject function");

lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class SwiftExpressionParser : public ExpressionParser {
8383
/// success.
8484
//------------------------------------------------------------------
8585
unsigned Parse(DiagnosticManager &diagnostic_manager, uint32_t first_line = 0,
86-
uint32_t last_line = UINT32_MAX) override;
86+
uint32_t last_line = UINT32_MAX);
8787

8888
//------------------------------------------------------------------
8989
/// Ready an already-parsed expression for execution, possibly

lldb/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,11 @@ bool SwiftUserExpression::Parse(DiagnosticManager &diagnostic_manager,
377377
exe_scope = exe_ctx.GetTargetPtr();
378378
} while (0);
379379

380-
m_parser =
381-
std::make_unique<SwiftExpressionParser>(exe_scope, *this, m_options);
382-
383-
unsigned error_code = m_parser->Parse(
380+
auto *swift_parser = new SwiftExpressionParser(exe_scope, *this, m_options);
381+
unsigned error_code = swift_parser->Parse(
384382
diagnostic_manager, first_body_line,
385383
first_body_line + source_code->GetNumBodyLines());
384+
m_parser.reset(swift_parser);
386385

387386
if (error_code == 2) {
388387
m_fixed_text = m_expr_text;

0 commit comments

Comments
 (0)