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);
678
678
// / Returns true if the given type is a C++ `const` reference type.
679
679
bool isCxxConstReferenceType (const clang::Type *type);
680
680
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);
681
687
} // namespace importer
682
688
683
689
struct ClangInvocationFileMapping {
Original file line number Diff line number Diff line change @@ -107,13 +107,6 @@ class CFPointeeInfo {
107
107
return Decl.get <const clang::TypedefNameDecl *>();
108
108
}
109
109
};
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);
117
110
}
118
111
}
119
112
Original file line number Diff line number Diff line change 31
31
#include " swift/IRGen/IRABIDetailsProvider.h"
32
32
#include " clang/AST/ASTContext.h"
33
33
#include " clang/AST/Attr.h"
34
+ #include " clang/AST/Decl.h"
34
35
#include " clang/AST/DeclObjC.h"
35
36
#include " llvm/ADT/STLExtras.h"
36
37
@@ -273,8 +274,13 @@ class CFunctionSignatureTypePrinter
273
274
bool isInOutParam) {
274
275
auto *cd = CT->getDecl ();
275
276
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 ? " " : " *" )
278
284
<< (!optionalKind || *optionalKind == OTK_None ? " _Nonnull"
279
285
: " _Nullable" );
280
286
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