forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 352
[lldb] Add support for symbolic extended existentials #10915
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
adrian-prantl
merged 1 commit into
swiftlang:stable/20240723
from
adrian-prantl:146273066
Aug 5, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
| SWIFT_SOURCES := main.swift | ||
|
|
||
| include Makefile.rules |
26 changes: 26 additions & 0 deletions
26
lldb/test/API/lang/swift/constrained_existential/TestSwiftConstrainedExistential.py
This file contains hidden or 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,26 @@ | ||
| import lldb | ||
| from lldbsuite.test.decorators import * | ||
| import lldbsuite.test.lldbtest as lldbtest | ||
| import lldbsuite.test.lldbutil as lldbutil | ||
|
|
||
|
|
||
| class TestSwiftConstrainedExistential(lldbtest.TestBase): | ||
| @swiftTest | ||
| def test(self): | ||
| """Test constrained existential types""" | ||
|
|
||
| self.build() | ||
| lldbutil.run_to_source_breakpoint(self, "break here", | ||
| lldb.SBFileSpec("main.swift")) | ||
| s0 = self.frame().FindVariable("s0") | ||
| self.assertEqual(s0.GetStaticValue().GetNumChildren(), 3+1+2) | ||
| self.assertEqual(s0.GetNumChildren(), 1) | ||
| i = s0.GetChildMemberWithName("i") | ||
| lldbutil.check_variable(self, i, value='23') | ||
|
|
||
| s = self.frame().FindVariable("s") | ||
| s = s.GetChildAtIndex(0) | ||
| self.assertEqual(s.GetStaticValue().GetNumChildren(), 6) | ||
| self.assertEqual(s.GetNumChildren(), 1) | ||
| i = s.GetChildMemberWithName("i") | ||
| lldbutil.check_variable(self, i, value='23') |
28 changes: 28 additions & 0 deletions
28
lldb/test/API/lang/swift/constrained_existential/main.swift
This file contains hidden or 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,28 @@ | ||
| protocol P1<U> { | ||
| associatedtype U | ||
| func get1() -> U | ||
| } | ||
|
|
||
| protocol P2<V> { | ||
| associatedtype V | ||
| func get2() -> V | ||
| } | ||
|
|
||
| struct Impl : P1<Int>, P2<(Int, Int)> { | ||
| let i = 23 | ||
| func get1() -> Int { return i } | ||
| func get2() -> (Int, Int) { return (4, 2) } | ||
| } | ||
|
|
||
| struct S<T> { | ||
| let s: any P1<T> & P2<(T, T)> | ||
| } | ||
|
|
||
| func f() { | ||
| let s0: any P1<Int> & P2<(Int, Int)> = Impl() | ||
| let s = S(s: Impl()) | ||
| print("break here") | ||
| } | ||
|
|
||
| f() | ||
|
|
3 changes: 3 additions & 0 deletions
3
lldb/test/API/lang/swift/symbolic_extended_existential/Makefile
This file contains hidden or 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 @@ | ||
| SWIFT_SOURCES := main.swift | ||
|
|
||
| include Makefile.rules |
48 changes: 48 additions & 0 deletions
48
...test/API/lang/swift/symbolic_extended_existential/TestSwiftSymbolicExtendedExistential.py
This file contains hidden or 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,48 @@ | ||
| import lldb | ||
| from lldbsuite.test.decorators import * | ||
| import lldbsuite.test.lldbtest as lldbtest | ||
| import lldbsuite.test.lldbutil as lldbutil | ||
|
|
||
|
|
||
| class TestSwiftSymbolicExtendedExistential(lldbtest.TestBase): | ||
|
|
||
| @swiftTest | ||
| def test(self): | ||
| """Test symbolic extended existentials""" | ||
| self.build() | ||
| lldbutil.run_to_source_breakpoint( | ||
| self, 'break here', lldb.SBFileSpec('main.swift')) | ||
|
|
||
| if self.TraceOn(): | ||
| self.runCmd("v -d run -L s") | ||
| frame = self.frame() | ||
| var_s = frame.FindVariable("s") | ||
| var_s_l0 = var_s.GetChildMemberWithName("l0") | ||
| var_s_l1 = var_s.GetChildMemberWithName("l1") | ||
| var_s_l2 = var_s.GetChildMemberWithName("l2") | ||
| var_s_l3 = var_s.GetChildMemberWithName("l3") | ||
| var_s_l4 = var_s.GetChildMemberWithName("l4") | ||
| var_s_l5 = var_s.GetChildMemberWithName("l5") | ||
| var_s_l6 = var_s.GetChildMemberWithName("l6") | ||
| lldbutil.check_variable(self, var_s_l0, value="0") | ||
| lldbutil.check_variable(self, var_s_l1, value="10") | ||
| lldbutil.check_variable(self, var_s_l2, value="20") | ||
| lldbutil.check_variable(self, var_s_l3, value="30") | ||
| lldbutil.check_variable(self, var_s_l4, value="40") | ||
| lldbutil.check_variable(self, var_s_l5, value="50") | ||
| lldbutil.check_variable(self, var_s_l6, value="60") | ||
| var_s_s1 = var_s.GetChildMemberWithName("s1") | ||
| var_s_s2 = var_s.GetChildMemberWithName("s2") | ||
| var_s_s3 = var_s.GetChildMemberWithName("s3") | ||
| var_s_s4 = var_s.GetChildMemberWithName("s4") | ||
| var_s_s5 = var_s.GetChildMemberWithName("s5") | ||
| var_s_s6 = var_s.GetChildMemberWithName("s6") | ||
| lldbutil.check_variable(self, var_s_s1, use_dynamic=True, summary="1...1") | ||
| lldbutil.check_variable(self, var_s_s2, use_dynamic=True, summary="1...200") | ||
| lldbutil.check_variable(self, var_s_s3, use_dynamic=True, summary="1...2") | ||
| lldbutil.check_variable(self, var_s_s4, use_dynamic=True, summary="nil") | ||
| lldbutil.check_variable(self, var_s_s5, use_dynamic=True, typename="a.C") | ||
| # FIXME: | ||
| # lldbutil.check_variable(self, var_s_s6, use_dynamic=True, summary="Int") | ||
|
|
||
| self.expect("expression -- s.s1", substrs=['1...1']) | ||
25 changes: 25 additions & 0 deletions
25
lldb/test/API/lang/swift/symbolic_extended_existential/main.swift
This file contains hidden or 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,25 @@ | ||
| class C {} | ||
|
|
||
| struct S { | ||
| let l0 = 0 | ||
| let s1 : any Sequence<Int> = 1...1 | ||
| let l1 = 10 | ||
| let s2 : any Sequence<Int> = 1...200 | ||
| let l2 = 20 | ||
| let s3 : (any Sequence<Int>)? = 1...2 | ||
| let l3 = 30 | ||
| let s4 : (any Sequence<Int>)? = nil | ||
| let l4 = 40 | ||
| let s5 : any AnyObject = C() | ||
| let l5 = 50 | ||
| let s6 : any Any.Type = Int.self | ||
| let l6 = 60 | ||
| } | ||
|
|
||
| func main() { | ||
| var s = S() | ||
| print("break here") | ||
| } | ||
|
|
||
| main() | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could create a bug report to track this, unless it's something you plan on fixing soon