Skip to content

Add a test for accessing private properties of resilient objects. #3193

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 1 commit into from
Sep 20, 2021
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
3 changes: 2 additions & 1 deletion lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3429,7 +3429,8 @@ swift::ASTContext *SwiftASTContext::GetASTContext() {
// 1. Create and install the memory buffer serialized module loader.
std::unique_ptr<swift::ModuleLoader> memory_buffer_loader_ap(
swift::MemoryBufferSerializedModuleLoader::create(
*m_ast_context_ap, m_dependency_tracker.get(), loading_mode));
*m_ast_context_ap, m_dependency_tracker.get(), loading_mode,
/*IgnoreSwiftSourceInfo*/ false, /*BypassResilience*/ true));
if (memory_buffer_loader_ap) {
m_memory_buffer_module_loader =
static_cast<swift::MemoryBufferSerializedModuleLoader *>(
Expand Down
4 changes: 4 additions & 0 deletions lldb/test/API/lang/swift/resilience_private_field/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SWIFT_SOURCES := main.swift
SWIFTFLAGS_EXTRAS := -enable-library-evolution

include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import lldb
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbtest as lldbtest
import lldbsuite.test.lldbutil as lldbutil
import unittest2


class TestSwiftResiliencePrivateField(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@swiftTest
def test(self):
self.build()
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
self, 'break here', lldb.SBFileSpec('main.swift'))

self.expect("frame variable -- self.m", substrs=['42'])
self.expect("expression -- m", substrs=['42'])
9 changes: 9 additions & 0 deletions lldb/test/API/lang/swift/resilience_private_field/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class C {
private var m: Int
public func use_m() {
print(m) // break here
}
public init() { m = 42 }
}

C().use_m()