-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[C++-Interop] Import const &T
function parameters as @in_guaranteed
#61000
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
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
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
15 changes: 15 additions & 0 deletions
15
test/Interop/Cxx/reference/Inputs/reference-silgen-cxx-objc-ctors+init.h
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 @@ | ||
|
||
|
||
@interface NSObject | ||
@end | ||
|
||
struct IntWrapper { | ||
int value; | ||
IntWrapper() = delete; | ||
IntWrapper(const int &value): value(value) {}; | ||
}; | ||
|
||
@interface ObjCSwiftBridge : NSObject | ||
- (instancetype)init __attribute__((unavailable)); | ||
- (instancetype)initWithEmbedded:(const IntWrapper &)embedded __attribute__((objc_designated_initializer)); | ||
@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
21 changes: 21 additions & 0 deletions
21
test/Interop/Cxx/reference/reference-silgen-cxx-objc-ctors+init.swift
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,21 @@ | ||
// REQUIRES: objc_interop | ||
// RUN: %target-swift-emit-sil -I %S/Inputs -enable-experimental-cxx-interop -Xcc -std=c++17 -Ounchecked %s | %FileCheck %s | ||
|
||
import ConstRefCxxObjCCtorInitParameter | ||
|
||
var a: Int32 = 32 | ||
var b = IntWrapper(a) | ||
var c = ObjCSwiftBridge(embedded: b) | ||
|
||
// FIXME: the const-ref C++ Consructor here is not getting an @in_guaranteed or even an @in convention here. | ||
// CHECK: {{%[0-9]+}} = function_ref @_ZN10IntWrapperC1ERKi : $@convention(c) (Int32) -> @out IntWrapper | ||
// CHECK: {{%[0-9]+}} = apply {{%[0-9]+}}({{%[0-9]+}}, {{%[0-9]+}}) : $@convention(c) (Int32) -> @out IntWrapper | ||
// CHECK: alloc_global @$s4main1cSo15ObjCSwiftBridgeCSgvp | ||
// CHECK: {{%[0-9]+}} = global_addr @$s4main1cSo15ObjCSwiftBridgeCSgvp : $*Optional<ObjCSwiftBridge> | ||
// CHECK: {{%[0-9]+}} = load {{%[0-9]+}} : $*IntWrapper | ||
// CHECK: {{%[0-9]+}} = alloc_ref [objc] $ObjCSwiftBridge | ||
// CHECK: {{%[0-9]+}} = alloc_stack $IntWrapper | ||
// CHECK: store {{%[0-9]+}} to {{%[0-9]+}} : $*IntWrapper | ||
// CHECK: {{%[0-9]+}} = objc_method {{%[0-9]+}} : $ObjCSwiftBridge, #ObjCSwiftBridge.init!initializer.foreign : (ObjCSwiftBridge.Type) -> (IntWrapper) -> ObjCSwiftBridge?, $@convention(objc_method) (@in_guaranteed IntWrapper, @owned ObjCSwiftBridge) -> @owned Optional<ObjCSwiftBridge> | ||
// CHECK: {{%[0-9]+}} = apply {{%[0-9]+}}({{%[0-9]+}}, {{%[0-9]+}}) : $@convention(objc_method) (@in_guaranteed IntWrapper, @owned ObjCSwiftBridge) -> @owned Optional<ObjCSwiftBridge> | ||
// CHECK: dealloc_stack {{%[0-9]+}} : $*IntWrapper |
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
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.
This one is the one that I was confused. IIUC
$sSo19OptionsConsumerObjCC7optionsABSo0A6StructV_tcfC
demangles to__C.OptionsConsumerObjC.__allocating_init(options: __C.OptionsStruct) -> __C.OptionsConsumerObjC
which seems to be an Obj-C initializer, and it does not have@in
nor@in_guaranteed
. I don't know if this is required, or in this case it is fine to pass a copy.But this one is different than in your new test, which shows a non-mangled name. I wonder if the designated initializer bit changes something.