forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 341
[lldb] Improve handling of artificial subclasses #7423
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
augusto2112
merged 1 commit into
swiftlang:stable/20221013
from
augusto2112:artificial-class
Sep 12, 2023
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,2 @@ | ||
SWIFT_SOURCES := main.swift | ||
include Makefile.rules |
22 changes: 22 additions & 0 deletions
22
lldb/test/API/lang/swift/artificial_subclass/TestSwiftArtificialSubclass.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,22 @@ | ||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
import unittest2 | ||
|
||
|
||
class TestSwiftArtificialSubclass(TestBase): | ||
@skipUnlessObjCInterop | ||
@swiftTest | ||
def test(self): | ||
""" Test that displaying an artificial type works correctly""" | ||
self.build() | ||
_, _, _, _ = lldbutil.run_to_source_breakpoint( | ||
self, "break here", lldb.SBFileSpec("main.swift") | ||
) | ||
|
||
|
||
self.expect( | ||
"frame variable m", | ||
substrs=["Subclass)", "Superclass", "a = 42", "b = 97"] | ||
) |
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,19 @@ | ||
import ObjectiveC | ||
|
||
class Superclass { | ||
let a = 42 | ||
} | ||
|
||
class Subclass: Superclass { | ||
let b = 97 | ||
|
||
override init() { | ||
super.init() | ||
let c: AnyClass = objc_allocateClassPair(Subclass.self, "DynamicSubclass", 0)! | ||
objc_registerClassPair(c); | ||
object_setClass(self, c) | ||
} | ||
} | ||
|
||
let m = Subclass() | ||
print(m) // break here |
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.
Is this an error, or expected? We might want to log it if it's an error.
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 it's expected, because this is normal for artificial base classes, maybe the comment could be more explicit about that?
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.
It's expected if the current class is artificial, I'll add 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.
is there a way we can know that the current class is artificial? In the case where the current class is not artificial, then we'd want a log or better.
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.
Remote Mirrors doesn't really tell us why getting the typeref failed (it could be an artificial class or conceivably something else). It'd be pretty straight forward to add an API asking if the class is artificial or not, if we want that.