Skip to content

Commit 2d7b7a7

Browse files
authored
[Swiftify] SafeInteropWrapper crashes with 'cgImage.width' (#80948)
* [Swiftify] Fix crash calling cgImage.width cgImage.width calls the C function, CGImageGetWidth(CGImageRef). Swift representation and Clang representation of this function seem to have a parameter number mismatch, causing swiftify function to crash. rdar://149691207 * [NFC] Fix test/Interop/ObjC/swiftify-import/getter.swift
1 parent 1c1f43f commit 2d7b7a7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4745,7 +4745,7 @@ namespace {
47454745
auto loc = Impl.importSourceLoc(decl->getLocation());
47464746
auto dc = Impl.importDeclContextOf(
47474747
decl, importedName.getEffectiveContext());
4748-
4748+
47494749
SmallVector<GenericTypeParamDecl *, 4> genericParams;
47504750
for (auto &param : *decl->getTemplateParameters()) {
47514751
auto genericParamDecl =
@@ -5528,7 +5528,7 @@ namespace {
55285528
objcClass->getDeclaredType());
55295529
Impl.SwiftContext.evaluator.cacheOutput(ExtendedNominalRequest{result},
55305530
std::move(objcClass));
5531-
5531+
55325532
Identifier categoryName;
55335533
if (!decl->getName().empty())
55345534
categoryName = Impl.SwiftContext.getIdentifier(decl->getName());
@@ -9155,6 +9155,9 @@ void ClangImporter::Implementation::swiftify(FuncDecl *MappedDecl) {
91559155
if (!ClangDecl)
91569156
return;
91579157

9158+
if (ClangDecl->getNumParams() != MappedDecl->getParameters()->size())
9159+
return;
9160+
91589161
llvm::SmallString<128> MacroString;
91599162
// We only attach the macro if it will produce an overload. Any __counted_by
91609163
// will produce an overload, since UnsafeBufferPointer is still an improvement
@@ -9570,7 +9573,7 @@ ClangImporter::Implementation::importDeclImpl(const clang::NamedDecl *ClangDecl,
95709573
Result = importDecl(UnderlyingDecl, version);
95719574
SkippedOverTypedef = true;
95729575
}
9573-
9576+
95749577
if (!Result) {
95759578
SwiftDeclConverter converter(*this, version);
95769579
Result = converter.Visit(ClangDecl);

0 commit comments

Comments
 (0)