Skip to content

[lldb] Allow "var" persistent variables to be modified #5651

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
Original file line number Diff line number Diff line change
Expand Up @@ -1633,14 +1633,10 @@ unsigned SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,

swift::VarDecl *decl = variable_info.GetDecl();
if (decl) {
if (decl->isLet()) {
llvm::cast<SwiftExpressionVariable>(persistent_variable.get())
->SetIsModifiable(false);
}
if (!decl->hasStorage()) {
llvm::cast<SwiftExpressionVariable>(persistent_variable.get())
->SetIsComputed(true);
}
auto swift_var =
llvm::cast<SwiftExpressionVariable>(persistent_variable.get());
swift_var->SetIsModifiable(!decl->isLet());
swift_var->SetIsComputed(!decl->hasStorage());
}

variable_info.m_metadata.reset(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SWIFT_SOURCES := main.swift
include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
import lldbsuite.test.lldbutil as lldbutil


class TestCase(TestBase):
@swiftTest
def test(self):
"""Test that persistent variables are mutable."""
self.build()
lldbutil.run_to_name_breakpoint(self, "main")
self.expect("expr var $count = 30")
self.expect("expr $count = 41")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// does nothing