File tree Expand file tree Collapse file tree 4 files changed +28
-9
lines changed
include/swift/ClangImporter
test/Interop/SwiftToCxx/stdlib Expand file tree Collapse file tree 4 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -678,6 +678,12 @@ getCxxReferencePointeeTypeOrNone(const clang::Type *type);
678678// / Returns true if the given type is a C++ `const` reference type.
679679bool isCxxConstReferenceType (const clang::Type *type);
680680
681+ // / Determine whether this typedef is a CF type.
682+ bool isCFTypeDecl (const clang::TypedefNameDecl *Decl);
683+
684+ // / Determine the imported CF type for the given typedef-name, or the empty
685+ // / string if this is not an imported CF type name.
686+ llvm::StringRef getCFTypeName (const clang::TypedefNameDecl *decl);
681687} // namespace importer
682688
683689struct ClangInvocationFileMapping {
Original file line number Diff line number Diff line change @@ -107,13 +107,6 @@ class CFPointeeInfo {
107107 return Decl.get <const clang::TypedefNameDecl *>();
108108 }
109109};
110-
111- // / Determine whether this typedef is a CF type.
112- bool isCFTypeDecl (const clang::TypedefNameDecl *Decl);
113-
114- // / Determine the imported CF type for the given typedef-name, or the empty
115- // / string if this is not an imported CF type name.
116- llvm::StringRef getCFTypeName (const clang::TypedefNameDecl *decl);
117110}
118111}
119112
Original file line number Diff line number Diff line change 3131#include " swift/IRGen/IRABIDetailsProvider.h"
3232#include " clang/AST/ASTContext.h"
3333#include " clang/AST/Attr.h"
34+ #include " clang/AST/Decl.h"
3435#include " clang/AST/DeclObjC.h"
3536#include " llvm/ADT/STLExtras.h"
3637
@@ -273,8 +274,13 @@ class CFunctionSignatureTypePrinter
273274 bool isInOutParam) {
274275 auto *cd = CT->getDecl ();
275276 if (cd->hasClangNode ()) {
276- ClangSyntaxPrinter (os).printClangTypeReference (cd->getClangDecl ());
277- os << " *"
277+ const auto *clangDecl = cd->getClangDecl ();
278+ ClangSyntaxPrinter (os).printClangTypeReference (clangDecl);
279+ bool alreadyPointer = false ;
280+ if (const auto *typedefDecl = dyn_cast<clang::TypedefNameDecl>(clangDecl))
281+ if (importer::isCFTypeDecl (typedefDecl))
282+ alreadyPointer = true ;
283+ os << (alreadyPointer ? " " : " *" )
278284 << (!optionalKind || *optionalKind == OTK_None ? " _Nonnull"
279285 : " _Nullable" );
280286 if (isInOutParam) {
Original file line number Diff line number Diff line change 1+ // RUN: %empty-directory(%t)
2+
3+ // RUN: %target-swift-frontend -typecheck %s -typecheck -module-name UseCoreFoundation -enable-experimental-cxx-interop -clang-header-expose-decls=all-public -emit-clang-header-path %t/UseCoreFoundation.h
4+ // RUN: %FileCheck %s < %t/UseCoreFoundation.h
5+
6+ // REQUIRES: objc_interop
7+
8+ import CoreFoundation
9+
10+ public func foobar( _ a: CFData ) -> Bool {
11+ true
12+ }
13+
14+ // CHECK: SWIFT_EXTERN bool $s17UseCoreFoundation6foobarySbSo9CFDataRefaF(CFDataRef _Nonnull a) SWIFT_NOEXCEPT SWIFT_CALL; // foobar(_:)
You can’t perform that action at this time.
0 commit comments