Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4036,9 +4036,13 @@ namespace {
}
if (selfIdx) {
func->setSelfIndex(selfIdx.value());
if (Impl.SwiftContext.LangOpts.hasFeature(
Feature::AddressableParameters))
func->getImplicitSelfDecl()->setAddressable();
// FIXME: Make this work when SIL Opaque Values are enabled.
// Currently, addressable parameters and opaque values are at odds.
if (!dc->getDeclaredInterfaceType()->hasReferenceSemantics() &&
!importedName.importAsMember() &&
!Impl.SwiftContext.SILOpts.EnableSILOpaqueValues)
func->getAttrs().add(new (Impl.SwiftContext)
AddressableSelfAttr(true));
} else {
func->setStatic();
func->setImportAsStaticMember();
Expand Down
5 changes: 4 additions & 1 deletion lib/SILGen/SILGenApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3717,7 +3717,10 @@ SILGenFunction::tryEmitAddressableParameterAsAddress(ArgumentSource &&arg,
// Materialize the base outside of the scope of the addressor call,
// since the returned address may depend on the materialized
// representation, even if it isn't transitively addressable.
auto baseTy = lookupExpr->getBase()->getType()->getCanonicalType();
auto baseTy = lookupExpr->getBase()
->getType()
->getWithoutSpecifierType()
->getCanonicalType();
ArgumentSource baseArg = prepareAccessorBaseArgForFormalAccess(
lookupExpr->getBase(), base, baseTy, addressorRef);

Expand Down
8 changes: 2 additions & 6 deletions test/ClangImporter/cxx_interop_ir.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// RUN: %target-swiftxx-frontend -module-name cxx_ir -I %S/Inputs/custom-modules -emit-ir -o - -primary-file %s -Xcc -fignore-exceptions | %FileCheck %s

// https://github.com/apple/swift/issues/55575
// We can't yet call member functions correctly on Windows.
// XFAIL: OS=windows-msvc

import CXXInterop

// CHECK-LABEL: define hidden swiftcc void @"$s6cxx_ir13indirectUsageyyF"()
Expand Down Expand Up @@ -42,8 +38,8 @@ func basicMethods(a: UnsafeMutablePointer<Methods>) -> Int32 {
}

// CHECK-LABEL: define hidden swiftcc i32 @"$s6cxx_ir17basicMethodsConst1as5Int32VSpySo0D0VG_tF"(ptr %0)
// CHECK: [[THIS_PTR1:%.*]] = alloca %TSo7MethodsV, align {{4|8}}
// CHECK: [[RESULT:%.*]] = call {{(signext )?}}i32 @{{_ZNK7Methods17SimpleConstMethodEi|"\?SimpleConstMethod@Methods@@QEBAHH@Z"}}(ptr [[THIS_PTR1]], i32 {{%?[0-9]+}})
// CHECK: [[THIS_PTR1:%.*]] = alloca ptr, align {{4|8}}
// CHECK: [[RESULT:%.*]] = call {{(signext )?}}i32 @{{_ZNK7Methods17SimpleConstMethodEi|"\?SimpleConstMethod@Methods@@QEBAHH@Z"}}(ptr %0, i32 {{%?[0-9]+}})
// CHECK: ret i32 [[RESULT]]
func basicMethodsConst(a: UnsafeMutablePointer<Methods>) -> Int32 {
return a.pointee.SimpleConstMethod(3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public func addressableTest(x: borrowing @_addressable NonTrivialInWrapper, y: i
// CHECK: %{{[0-9]+}} = apply %{{[0-9]+}}([[UNWRAPPED]], %{{[0-9]+}}) : $@convention(cxx_method) (@in_guaranteed NonTrivialInWrapper, @in_guaranteed HasMethods) -> ()
var m2 = HasMethods()
// CHECK: [[ACCESS:%[0-9]+]] = begin_access [modify] [unknown] [[INPUT2]]
// CHECK: %{{[0-9]+}} = apply %32([[ACCESS]], %{{[0-9]+}}) : $@convention(cxx_method) (@inout NonTrivialInWrapper, @in_guaranteed HasMethods) -> ()
// CHECK: %{{[0-9]+}} = apply %{{[0-9]+}}([[ACCESS]], %{{[0-9]+}}) : $@convention(cxx_method) (@inout NonTrivialInWrapper, @in_guaranteed HasMethods) -> ()
// CHECK-NEXT: end_access [[ACCESS]]
m2.nonTrivialTakesRef(&y)
}