Skip to content

Commit 203ee39

Browse files
authored
[Swiftify] SafeInteropWrapper crashes with 'cgImage.width' (#81075)
* [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 (cherry picked from commit af8579f) * [NFC] Fix test/Interop/ObjC/swiftify-import/getter.swift
1 parent c5acba5 commit 203ee39

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
@@ -4686,7 +4686,7 @@ namespace {
46864686
auto loc = Impl.importSourceLoc(decl->getLocation());
46874687
auto dc = Impl.importDeclContextOf(
46884688
decl, importedName.getEffectiveContext());
4689-
4689+
46904690
SmallVector<GenericTypeParamDecl *, 4> genericParams;
46914691
for (auto &param : *decl->getTemplateParameters()) {
46924692
auto genericParamDecl =
@@ -5469,7 +5469,7 @@ namespace {
54695469
objcClass->getDeclaredType());
54705470
Impl.SwiftContext.evaluator.cacheOutput(ExtendedNominalRequest{result},
54715471
std::move(objcClass));
5472-
5472+
54735473
Identifier categoryName;
54745474
if (!decl->getName().empty())
54755475
categoryName = Impl.SwiftContext.getIdentifier(decl->getName());
@@ -9096,6 +9096,9 @@ void ClangImporter::Implementation::swiftify(FuncDecl *MappedDecl) {
90969096
if (!ClangDecl)
90979097
return;
90989098

9099+
if (ClangDecl->getNumParams() != MappedDecl->getParameters()->size())
9100+
return;
9101+
90999102
llvm::SmallString<128> MacroString;
91009103
// We only attach the macro if it will produce an overload. Any __counted_by
91019104
// will produce an overload, since UnsafeBufferPointer is still an improvement
@@ -9511,7 +9514,7 @@ ClangImporter::Implementation::importDeclImpl(const clang::NamedDecl *ClangDecl,
95119514
Result = importDecl(UnderlyingDecl, version);
95129515
SkippedOverTypedef = true;
95139516
}
9514-
9517+
95159518
if (!Result) {
95169519
SwiftDeclConverter converter(*this, version);
95179520
Result = converter.Visit(ClangDecl);

0 commit comments

Comments
 (0)