Skip to content

Commit 5443baa

Browse files
authored
Merge pull request swiftlang#40599 from beccadax/ahead-of-its-time
Don't try to import variants for FieldDecls
2 parents 0b74cb1 + a9bd88a commit 5443baa

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4251,6 +4251,13 @@ namespace {
42514251
if (!importedName) {
42524252
return nullptr;
42534253
}
4254+
if (correctSwiftName) {
4255+
// FIXME: We should import this as a variant, but to do that, we'll also
4256+
// need to make this a computed variable or otherwise fix how the rest
4257+
// of the compiler thinks about stored properties in imported structs.
4258+
// For now, just don't import it at all. (rdar://86069786)
4259+
return nullptr;
4260+
}
42544261

42554262
auto name = importedName.getDeclName().getBaseIdentifier();
42564263

@@ -4301,6 +4308,7 @@ namespace {
43014308

43024309
// If this is a compatibility stub, handle it as such.
43034310
if (correctSwiftName)
4311+
// FIXME: Temporarily unreachable because of check above.
43044312
markAsVariant(result, *correctSwiftName);
43054313

43064314
return result;

test/ClangImporter/ctypes_ir.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,12 @@ func testBigArrays(_ maxSize: UnsafeMutablePointer<Int8>?, _ maxSizePlusOne: Uns
4545
func testBigArrays2d(_ maxSize: UnsafeMutablePointer<IntTuple4096>?, _ maxSizePlusOne: OpaquePointer?) {
4646
useBigArray2d(maxSize, maxSizePlusOne)
4747
}
48+
49+
50+
// Make sure fields with a swift_name attribute only produce one stored
51+
// property, not two. (rdar://86069786)
52+
// CHECK-LABEL: define swiftcc void @"$s9ctypes_ir22testFieldWithSwiftName1oySo12Rdar86069786V_tF"
53+
// CHECK-SAME: (double %0)
54+
55+
public func testFieldWithSwiftName(o : Rdar86069786) {
56+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ STDLIB_TYPEDEF(unsigned int, UInt);
196196
void noreturnFunction() __attribute__((noreturn));
197197
void couldReturnFunction() __attribute__((noreturn));
198198

199+
// Struct with an __attribute((swift_name)) field.
200+
struct Rdar86069786 {
201+
double c_name __attribute__((swift_name("swiftName")));
202+
};
203+
199204

200205
//===---
201206
// Function pointers

0 commit comments

Comments
 (0)