Skip to content

Don't try to import variants for FieldDecls #40599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4251,6 +4251,13 @@ namespace {
if (!importedName) {
return nullptr;
}
if (correctSwiftName) {
// FIXME: We should import this as a variant, but to do that, we'll also
// need to make this a computed variable or otherwise fix how the rest
// of the compiler thinks about stored properties in imported structs.
// For now, just don't import it at all. (rdar://86069786)
return nullptr;
}

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

Expand Down Expand Up @@ -4301,6 +4308,7 @@ namespace {

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

return result;
Expand Down
9 changes: 9 additions & 0 deletions test/ClangImporter/ctypes_ir.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,12 @@ func testBigArrays(_ maxSize: UnsafeMutablePointer<Int8>?, _ maxSizePlusOne: Uns
func testBigArrays2d(_ maxSize: UnsafeMutablePointer<IntTuple4096>?, _ maxSizePlusOne: OpaquePointer?) {
useBigArray2d(maxSize, maxSizePlusOne)
}


// Make sure fields with a swift_name attribute only produce one stored
// property, not two. (rdar://86069786)
// CHECK-LABEL: define swiftcc void @"$s9ctypes_ir22testFieldWithSwiftName1oySo12Rdar86069786V_tF"
// CHECK-SAME: (double %0)

public func testFieldWithSwiftName(o : Rdar86069786) {
}
5 changes: 5 additions & 0 deletions test/Inputs/clang-importer-sdk/usr/include/ctypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ STDLIB_TYPEDEF(unsigned int, UInt);
void noreturnFunction() __attribute__((noreturn));
void couldReturnFunction() __attribute__((noreturn));

// Struct with an __attribute((swift_name)) field.
struct Rdar86069786 {
double c_name __attribute__((swift_name("swiftName")));
};


//===---
// Function pointers
Expand Down