-
Notifications
You must be signed in to change notification settings - Fork 364
[lldb][NativePDB] Recognize bound generic pattern #12824
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
base: stable/21.x
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,15 @@ enum Direction { | |
| case south | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is a NativePDB test, is it running on macOS? Asking since the lldb swift tests are currently not enabled on Windows.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As of #12610 yes, unless something changed (I know because I had to remove the XFAIL on this test to land it!)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, I misread the question. It's not running on macOS (requires |
||
| } | ||
|
|
||
| struct Box<T> { | ||
| var value: T | ||
| } | ||
|
|
||
| enum Pair<A, B> { | ||
| case first(A) | ||
| case second(B) | ||
| } | ||
|
|
||
| func main() { | ||
| var myInt32: Int32 = 42 | ||
| var myBool: Bool = true | ||
|
|
@@ -27,20 +36,27 @@ func main() { | |
| var myString: String = "hello" | ||
| var myPoint: Point = Point(x: 10, y: 20) | ||
| var myDirection: Direction = .north | ||
| var myOptional: Int32? = 7 | ||
| var myArray: [Int32] = [1, 2, 3] | ||
| var myOptionalArray: [Int32]? = [4, 5] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this generalize to a nested type like
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, added a test case |
||
| var myResult: Result<Int, Error> = .success(42) | ||
| var myBox: Box<Int32> = Box(value: 99) | ||
| var myPair: Pair<Int, String> = .first(7) | ||
| let constInt: Int = 100 | ||
| let constInt8: Int8 = -42 | ||
| let constUInt16: UInt16 = 1000 | ||
| let constBool: Bool = false | ||
| let constString: String = "world" | ||
| print(myInt32, myBool, myUInt64, myFloat, myDouble, | ||
| myString, myPoint, myDirection, | ||
| myString, myPoint, myDirection, myOptional, myArray, | ||
| myOptionalArray, myResult, myBox, myPair, | ||
| constInt, constInt8, constUInt16, constBool, constString) | ||
| } | ||
|
|
||
| main() | ||
|
|
||
| #--- commands.input | ||
| b main.swift:25 | ||
| b main.swift:40 | ||
| run | ||
| frame variable | ||
|
|
||
|
|
@@ -54,6 +70,12 @@ frame variable | |
| # CHECK: (String) myString = "hello" | ||
| # CHECK: (main.Point) myPoint = (x = 10, y = 20) | ||
| # CHECK: (main.Direction) myDirection = north | ||
| # CHECK: (Int32?) myOptional = 7 | ||
| # CHECK: ([Int32]) myArray = 3 values | ||
| # CHECK: ([Int32]?) myOptionalArray = 2 values | ||
| # CHECK: (Result<Int, Error>) myResult = success | ||
| # CHECK: (main.Box<Int32>) myBox = (value = 99) | ||
| # CHECK: (main.Pair<Int, String>) myPair = first | ||
| # Local constants | ||
| # CHECK: (Int) constInt = 100 | ||
| # CHECK: (Int8) constInt8 = -42 | ||
|
|
||
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.
Given the example you gave here: swiftlang/swift#87093 (comment), could MSVC emit
::<unnamed-tag>for a C/C++ type?If tha'ts the case, this
IsSwiftTypewould returntrueon a non Swift type.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.
If this is possible, we should:
swift-frame-var.test.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.
Yup, I can wire the field-list walk up twice. My thinking for not doing it was the perf gain and of not doing it is worth the edge case (no unique name, no name C/C++ type that nevertheless has something useful that TypeSystemClang can squeeze out of it) and cleaner code. I think probably both the perf hit is small and the edge case is not likely to matter though.
What would a good negative case look like?
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.
I tried to build a C++ type that has
::<unnamed-tag>in its name and does not have a unique name but I could not manage to do it. That would have been a good negative test but it does not seem to be possible.My concern was unfounded.
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.
Yep, AFAICT Clang can't produce it, but maybe another compiler can? I added the full check to
IsSwiftTypesince the perf hit isn't that bad and the cognitive overhead is probably worth us being sure.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.
I tried with MSVC but couldn't figure it out either.