forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 352
[lldb] Implement direct ivar access for Swift #6452
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
kastiglione
merged 5 commits into
stable/20221013
from
dl/this-or-self-ivar-direct-access
Mar 22, 2023
Merged
[lldb] Implement direct ivar access for Swift #6452
kastiglione
merged 5 commits into
stable/20221013
from
dl/this-or-self-ivar-direct-access
Mar 22, 2023
Conversation
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
Author
|
@swift-ci test |
This applies to IsClassMethod as well. (cherry picked from commit 77d2f26)
Add basic tests for `frame variable`'s ability to direct access fields of `this` and ivars of `self`. This splits the tests, preventing ObjC tests from running on Linux. Differential Revision: https://reviews.llvm.org/D145348 (cherry picked from commit 23ee705)
The `v` (`frame variable`) command can directly access ivars/fields of `this` or `self`.
Such as `v field`, instead of `v this->field`. This change relaxes the criteria for
finding `this`/`self` variables.
There are cases where a `this`/`self` variable does exist, but up to now the `v` command
has not made use of it. The user would have to explicitly run `v this->field` or
`self->_ivar` to access ivars. This change allows such cases to also work (without
explicitly dereferencing `this`/`self`).
A very common example in Objective-C (and Swift) is weakly capturing `self`:
```
__weak Type *weakSelf = self;
void (^block)(void) = ^{
Type *self = weakSelf; // Re-establish strong reference.
// `v _ivar` should work just as well as `v self->_ivar`.
};
```
In this case, `self` exists but `v` would not have used it. With this change, the fact
that a variable named `self` exists is enough for it to be used.
Differential Revision: https://reviews.llvm.org/D145276
(cherry picked from commit 6c599b1)
Move responsibility of providing the instance variable name (`this`, `self`) from `TypeSystem` to `Language`. `Language` the natural place for this, but also has downstream benefits. Some languages have multiple `TypeSystem` implementations (ex Swift), and by placing this logic in the `Language`, redundancy is avoided. This change relies on the tests from D145348 and D146320. Differential Revision: https://reviews.llvm.org/D146548 (cherry picked from commit 0a7488d72ceb59942cc14f567d77f2e97f72a2e4)
e6fbf4c to
b6a93e2
Compare
Author
|
@swift-ci test |
b6a93e2 to
1946914
Compare
Author
|
@swift-ci test |
adrian-prantl
approved these changes
Mar 22, 2023
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.
Nice!
augusto2112
approved these changes
Mar 22, 2023
augusto2112
left a comment
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.
This is great!
1946914 to
47e8dc8
Compare
Author
|
@swift-ci test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
frame variablecan print "ivars" directly (as lldb calls them, or equivalently "properties" in Swift parlance), without the user explicitly going throughthisorself.This PR cherry picks upstream LLVM refactoring commits, and adds a single Swift specific commit: "Support direct ivar access in Swift".
Example:
Inside
run():