Skip to content

Commit 512182b

Browse files
authored
Merge pull request #5790 from augusto2112/move-local-vars-eval
[lldb][NFC] Move discovery of local variables earlier in expr eval
2 parents dbdd828 + 8d91261 commit 512182b

File tree

4 files changed

+288
-246
lines changed

4 files changed

+288
-246
lines changed

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,29 @@ class SwiftASTManipulatorBase {
5959
unsigned GetType() override { return Type(); }
6060
};
6161

62+
class VariableMetadataPersistent
63+
: public SwiftASTManipulatorBase::VariableMetadata {
64+
public:
65+
VariableMetadataPersistent(
66+
lldb::ExpressionVariableSP &persistent_variable_sp)
67+
: m_persistent_variable_sp(persistent_variable_sp) {}
68+
69+
static constexpr unsigned Type() { return 'Pers'; }
70+
unsigned GetType() override { return Type(); }
71+
lldb::ExpressionVariableSP m_persistent_variable_sp;
72+
};
73+
74+
class VariableMetadataVariable
75+
: public SwiftASTManipulatorBase::VariableMetadata {
76+
public:
77+
VariableMetadataVariable(lldb::VariableSP &variable_sp)
78+
: m_variable_sp(variable_sp) {}
79+
80+
static constexpr unsigned Type() { return 'Vari'; }
81+
unsigned GetType() override { return Type(); }
82+
lldb::VariableSP m_variable_sp;
83+
};
84+
6285
typedef std::shared_ptr<VariableMetadata> VariableMetadataSP;
6386

6487
struct VariableInfo {
@@ -75,8 +98,8 @@ class SwiftASTManipulatorBase {
7598
VariableInfo() : m_type(), m_name(), m_metadata() {}
7699

77100
VariableInfo(CompilerType &type, swift::Identifier name,
78-
VariableMetadataSP metadata,
79-
swift::VarDecl::Introducer introducer,
101+
VariableMetadataSP metadata,
102+
swift::VarDecl::Introducer introducer,
80103
bool is_capture_list = false)
81104
: m_type(type), m_name(name), m_var_introducer(introducer),
82105
m_is_capture_list(is_capture_list), m_metadata(metadata) {}
@@ -132,8 +155,8 @@ class SwiftASTManipulatorBase {
132155

133156
/// The function containing the expression's code.
134157
swift::FuncDecl *m_function_decl = nullptr;
135-
/// The entrypoint function. Null if evaluating an expression outside a method,
136-
/// $__lldb_expr otherswise.
158+
/// The entrypoint function. Null if evaluating an expression outside a
159+
/// method, $__lldb_expr otherswise.
137160
swift::FuncDecl *m_entrypoint_decl = nullptr;
138161
/// If evaluating in a generic context, the trampoline function that calls the
139162
/// method with the user's expression, null otherwise.

0 commit comments

Comments
 (0)