Skip to content

Commit f878282

Browse files
authored
Merge pull request #40600 from beccadax/ahead-of-its-time-5.6
[5.6] Don't try to import variants for FieldDecls
2 parents d3f803e + 0944c26 commit f878282

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
@@ -4206,6 +4206,13 @@ namespace {
42064206
if (!importedName) {
42074207
return nullptr;
42084208
}
4209+
if (correctSwiftName) {
4210+
// FIXME: We should import this as a variant, but to do that, we'll also
4211+
// need to make this a computed variable or otherwise fix how the rest
4212+
// of the compiler thinks about stored properties in imported structs.
4213+
// For now, just don't import it at all. (rdar://86069786)
4214+
return nullptr;
4215+
}
42094216

42104217
auto name = importedName.getDeclName().getBaseIdentifier();
42114218

@@ -4248,6 +4255,7 @@ namespace {
42484255

42494256
// If this is a compatibility stub, handle it as such.
42504257
if (correctSwiftName)
4258+
// FIXME: Temporarily unreachable because of check above.
42514259
markAsVariant(result, *correctSwiftName);
42524260

42534261
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)