Skip to content

[lldb][NFC] Move discovery of local variables earlier in expr eval #5790

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
31 changes: 27 additions & 4 deletions lldb/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@ class SwiftASTManipulatorBase {
unsigned GetType() override { return Type(); }
};

class VariableMetadataPersistent
: public SwiftASTManipulatorBase::VariableMetadata {
public:
VariableMetadataPersistent(
lldb::ExpressionVariableSP &persistent_variable_sp)
: m_persistent_variable_sp(persistent_variable_sp) {}

static constexpr unsigned Type() { return 'Pers'; }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea what this is used for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the metadata type controls how materialization works. It's only used in MaterializeVariable

unsigned GetType() override { return Type(); }
lldb::ExpressionVariableSP m_persistent_variable_sp;
};

class VariableMetadataVariable
: public SwiftASTManipulatorBase::VariableMetadata {
public:
VariableMetadataVariable(lldb::VariableSP &variable_sp)
: m_variable_sp(variable_sp) {}

static constexpr unsigned Type() { return 'Vari'; }
unsigned GetType() override { return Type(); }
lldb::VariableSP m_variable_sp;
};

typedef std::shared_ptr<VariableMetadata> VariableMetadataSP;

struct VariableInfo {
Expand All @@ -75,8 +98,8 @@ class SwiftASTManipulatorBase {
VariableInfo() : m_type(), m_name(), m_metadata() {}

VariableInfo(CompilerType &type, swift::Identifier name,
VariableMetadataSP metadata,
swift::VarDecl::Introducer introducer,
VariableMetadataSP metadata,
swift::VarDecl::Introducer introducer,
bool is_capture_list = false)
: m_type(type), m_name(name), m_var_introducer(introducer),
m_is_capture_list(is_capture_list), m_metadata(metadata) {}
Expand Down Expand Up @@ -132,8 +155,8 @@ class SwiftASTManipulatorBase {

/// The function containing the expression's code.
swift::FuncDecl *m_function_decl = nullptr;
/// The entrypoint function. Null if evaluating an expression outside a method,
/// $__lldb_expr otherswise.
/// The entrypoint function. Null if evaluating an expression outside a
/// method, $__lldb_expr otherswise.
swift::FuncDecl *m_entrypoint_decl = nullptr;
/// If evaluating in a generic context, the trampoline function that calls the
/// method with the user's expression, null otherwise.
Expand Down
Loading