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
6 changes: 4 additions & 2 deletions lib/PrintAsClang/PrintClangFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,8 @@ static bool isOptionalForeignReferenceType(Type ty) {
if (auto obj = ty->getOptionalObjectType()) {
if (const auto *cd =
dyn_cast_or_null<ClassDecl>(obj->getNominalOrBoundGenericNominal()))
return cd->isForeignReferenceType();
return cd->isForeignReferenceType() ||
cd->getForeignClassKind() == ClassDecl::ForeignKind::CFType;
}
return false;
}
Expand Down Expand Up @@ -1780,7 +1781,8 @@ bool DeclAndTypeClangFunctionPrinter::hasKnownOptionalNullableCxxMapping(
return typeInfo->canBeNullable;
}
if (const auto *cd = dyn_cast<ClassDecl>(nominal))
if (cd->isForeignReferenceType())
if (cd->isForeignReferenceType() ||
cd->getForeignClassKind() == ClassDecl::ForeignKind::CFType)
return true;
return isa_and_nonnull<clang::ObjCInterfaceDecl>(nominal->getClangDecl());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public func foobar(_ a: CFData) -> Bool {
true
}

public func returnsCFDate() -> CFDate? {
nil
}

public func takesCFDate(x: CFDate?) {}

public func networkThing() -> in_addr? {
return nil
}
Expand All @@ -25,4 +31,9 @@ public enum MyEnum {
}

// CHECK: SWIFT_EXTERN bool $s17UseCoreFoundation6foobarySbSo9CFDataRefaF(CFDataRef _Nonnull a) SWIFT_NOEXCEPT SWIFT_CALL; // foobar(_:)
// CHECK: SWIFT_EXTERN CFDateRef _Nullable $s17UseCoreFoundation13returnsCFDateSo0E3RefaSgyF(void) SWIFT_NOEXCEPT SWIFT_CALL; // returnsCFDate()
// CHECK: SWIFT_EXTERN void $s17UseCoreFoundation11takesCFDate1xySo0E3RefaSg_tF(CFDateRef _Nullable x) SWIFT_NOEXCEPT SWIFT_CALL; // takesCFDate(x:)

// CHECK: SWIFT_INLINE_THUNK swift::Optional<in_addr> networkThing() noexcept SWIFT_SYMBOL("s:17UseCoreFoundation12networkThingSo7in_addrVSgyF") SWIFT_WARN_UNUSED_RESULT {
// CHECK: SWIFT_INLINE_THUNK CFDateRef _Nullable returnsCFDate() noexcept SWIFT_SYMBOL("s:17UseCoreFoundation13returnsCFDateSo0E3RefaSgyF") SWIFT_WARN_UNUSED_RESULT {
// CHECK: SWIFT_INLINE_THUNK void takesCFDate(CFDateRef _Nullable x) noexcept SWIFT_SYMBOL("s:17UseCoreFoundation11takesCFDate1xySo0E3RefaSg_tF") {