Skip to content

Commit fdd904b

Browse files
authored
Merge pull request #20840 from compnerd/CFTypes
[5.0] statically map CF types in the ClangImporter
2 parents 371de68 + 7ba61f0 commit fdd904b

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

lib/ClangImporter/MappedTypes.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ MAP_TYPE("CGFloat", CGFloat, 0, "CoreGraphics", "CGFloat", false, DoNothing)
161161

162162
// CoreFoundation types.
163163
// Note that we're preserving the typealias for CFIndex.
164+
MAP_STDLIB_TYPE("CFTypeID", UnsignedWord, 0, "UInt", false, DefineAndUse)
165+
MAP_STDLIB_TYPE("CFOptionFlags", UnsignedWord, 0, "UInt", false, DefineAndUse)
166+
MAP_STDLIB_TYPE("CFHashCode", UnsignedWord, 0, "UInt", false, DefineAndUse)
164167
MAP_STDLIB_TYPE("CFIndex", SignedWord, 0, "Int", false, DefineAndUse)
165168

166169
// Foundation types.

test/ClangImporter/ctypes_parse_objc.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,17 @@ func testImportMacTypes() {
7070
}
7171

7272
func testImportCFTypes() {
73-
let t1_unqual: Int = CFIndex_test
74-
_ = t1_unqual as CoreFoundation.CFIndex
73+
let t1_unqual: UInt = CFTypeID_test
74+
_ = t1_unqual as CoreFoundation.CFTypeID
75+
76+
let t2_unqual: UInt = CFOptionFlags_test
77+
_ = t2_unqual as CoreFoundation.CFOptionFlags
78+
79+
let t3_unqual: UInt = CFHashCode_test
80+
_ = t3_unqual as CoreFoundation.CFHashCode
81+
82+
let t4_unqual: Int = CFIndex_test
83+
_ = t4_unqual as CoreFoundation.CFIndex
7584
}
7685

7786
func testImportSEL() {

test/Inputs/clang-importer-sdk/usr/include/CoreFoundation.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,21 @@ typedef struct __attribute__((objc_bridge(NSSet))) __CFSet const *CFSetRef;
1818

1919
typedef CFTypeRef CFAliasForTypeRef;
2020

21-
21+
#if __LLP64__
22+
typedef unsigned long long CFTypeID;
23+
typedef unsigned long long CFOptionFlags;
24+
typedef unsigned long long CFHashCode;
25+
typedef signed long long CFIndex;
26+
#else
27+
typedef unsigned long CFTypeID;
28+
typedef unsigned long CFOptionFlags;
29+
typedef unsigned long CFHashCode;
2230
typedef signed long CFIndex;
31+
#endif
32+
33+
extern CFTypeID CFTypeID_test;
34+
extern CFOptionFlags CFOptionFlags_test;
35+
extern CFHashCode CFHashCode_test;
2336
extern CFIndex CFIndex_test;
2437

2538
#define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type

0 commit comments

Comments
 (0)