forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 344
[lldb] Add test for @objc @implementation #10889
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 4 commits into
swift/release/6.2
from
dl/lldb-Add-test-for-objc-implementation
Jul 1, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface Gadget : NSObject | ||
@property(nonatomic, assign) NSInteger integer; | ||
@property(nonatomic, assign) BOOL boolean; | ||
@property(nonatomic, strong) NSObject *object; | ||
@property(nonatomic, copy) NSString *string; | ||
@property(nonatomic, copy) NSObject *stringObject; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
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,4 @@ | ||
SWIFT_SOURCES = main.swift | ||
SWIFT_BRIDGING_HEADER = Gadget.h | ||
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO | ||
include Makefile.rules |
29 changes: 29 additions & 0 deletions
29
lldb/test/API/lang/swift/objc_implementation/TestSwiftObjCImplementation.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,29 @@ | ||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
|
||
|
||
class TestCase(TestBase): | ||
|
||
@swiftTest | ||
@skipUnlessFoundation | ||
def test(self): | ||
self.build() | ||
lldbutil.run_to_source_breakpoint( | ||
self, "break here", lldb.SBFileSpec("main.swift") | ||
) | ||
self.expect( | ||
"frame var g", | ||
substrs=[ | ||
"integer = 15", | ||
"object = some", | ||
'stringObject = "Joker"', | ||
], | ||
# On x86_64, BOOL types have an objc encoding of 'c', which is a | ||
# signed char. The result is in an output of '\x01'. | ||
patterns=[r"boolean = (true|'\\x01')"], | ||
) | ||
# Swift types that are not representable in ObjC (bridged types such as | ||
# String) are not currently listed in the children. rdar://154046212 | ||
self.expect("frame var g", matching=False, substrs=['string = "Ace"']) |
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,15 @@ | ||
@objc @implementation | ||
extension Gadget { | ||
var integer: Int = 15 | ||
var boolean: Bool = true | ||
var object: NSObject = NSObject() | ||
var string: String = "Ace" | ||
var stringObject: NSObject = "Joker" as NSString | ||
} | ||
|
||
func main() { | ||
let g = Gadget() | ||
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.
Out of curiosity — why is this needed?
(It basically removes DWARF for the types in the header, so I'm curious if the test depends on the missing debug info)
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.
yes the test depends on the absence of debug info (to emulate system or third party libraries). Is there a better way to do this?
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.
For the clangimported part, this is probably them most convenient solution. Maybe we could add a comment like