forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb] Add an expression evaluation test for modules built with
-enable-testing and -enable-library-evolution -enable-testing affects the visibility of types, which together with -enable-library-evolution may cause the compiler embedded in LLDB to generate incorrect code on expression evaluation.
- Loading branch information
1 parent
d36699c
commit 08233a5
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
SWIFT_SOURCES := main.swift | ||
|
||
all: libPublic.dylib a.out | ||
|
||
include Makefile.rules | ||
LD_EXTRAS = -lPublic -L$(BUILDDIR) | ||
SWIFTFLAGS_EXTRAS = -I$(BUILDDIR) | ||
|
||
libPublic.dylib: Public.swift | ||
"$(MAKE)" MAKE_DSYM=YES CC=$(CC) SWIFTC=$(SWIFTC) \ | ||
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \ | ||
BASENAME=Public \ | ||
SWIFTFLAGS_EXTRAS="-I$(BUILDDIR) -enable-library-evolution -enable-testing" \ | ||
VPATH=$(SRCDIR) -I $(SRCDIR) \ | ||
DYLIB_ONLY:=YES DYLIB_NAME=Public \ | ||
DYLIB_SWIFT_SOURCES:=Public.swift \ | ||
-f $(MAKEFILE_RULES) | ||
|
||
clean:: | ||
"$(MAKE)" BASENAME=Public VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/dylib.mk clean | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class SomeClass { | ||
let value = 42 | ||
} | ||
|
||
class ClassWithProperty { | ||
private var v = SomeClass() | ||
|
||
func f() { | ||
print("break here") | ||
} | ||
} | ||
|
||
public func entry() { | ||
ClassWithProperty().f() | ||
} |
21 changes: 21 additions & 0 deletions
21
lldb/test/API/lang/swift/enable_testing/TestSwiftEnableTesting.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
|
||
|
||
class TestSwiftEnableTesting(TestBase): | ||
|
||
def setUp(self): | ||
TestBase.setUp(self) | ||
|
||
@swiftTest | ||
def test(self): | ||
"""Test that expression evaluation generates a direct member access to a private property in a module compiled with -enable-library-evolution and -enable-testing""" | ||
|
||
self.build() | ||
target, process, _, _ = lldbutil.run_to_source_breakpoint( | ||
self, "break here", lldb.SBFileSpec("Public.swift"), extra_images=["Public"] | ||
) | ||
|
||
self.expect("expression v", substrs=["Public.SomeClass", "value = 42"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Public | ||
|
||
entry() |