[lldb] Name UnsafePointer's single child 'pointee' #3264
Merged
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.
Currently, the builtin formatter for
UnsafePointer
andUnsafeMutablePointer
provide a single child, which is named[0]
. This changes that child to be namedpointee
. This has two advantages:First, it enables
v ptr.pointee
to work, which matchesp ptr.pointee
. This is typically how unsafe pointers access their contents, not via subscript.Second, it avoids a behavior that looks like a bug to the user. For example:
On that last line, running
v ptr
produces:Both
UnsafePointer
andUnsafeMutablePointer
will only ever print the single child. A user may think their data is wrong, when it's in fact correct (because they aren't shown the second value). Or, they might think lldb has a bug, when in fact printing a single child expected behavior. Unless I have missed something,Unsafe(Mutable)?Pointer
does not capture state that would indicate it was created with a specific capacity, that information is "erased". If a capacity were available at runtime, lldb could print all of the children.Note that with this change
v ptr[0]
still succeeds, so that behavior is maintained. Also note thatv ptr[1]
does not currently work regardless of whether it's valid. This is because the provider reports only 1 child. The work around is to runp ptr[1]
.After this change, the above
v
command prints:rdar://83155374