Skip to content

Commit a8cab09

Browse files
committed
Add crashing test
1 parent d788713 commit a8cab09

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9159,6 +9159,8 @@ void ClangImporter::Implementation::swiftify(FuncDecl *MappedDecl) {
91599159
returnHasLifetimeInfo = true;
91609160
}
91619161
for (auto [index, clangParam] : llvm::enumerate(ClangDecl->parameters())) {
9162+
if (index >= MappedDecl->getParameters()->size())
9163+
break;
91629164
auto clangParamTy = clangParam->getType();
91639165
auto swiftParam = MappedDecl->getParameters()->get(index);
91649166
bool paramHasBoundsInfo = false;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// REQUIRES: swift_feature_SafeInteropWrappers
2+
3+
// RUN: rm -rf %t
4+
// RUN: split-file %s %t
5+
// RUN: %target-swift-ide-test -plugin-path %swift-plugin-dir -I %t/Inputs -enable-experimental-feature SafeInteropWrappers -print-module -module-to-print=Method -source-filename=x | %FileCheck %s
6+
// RUN: %target-swift-frontend -plugin-path %swift-plugin-dir -I %t/Inputs -enable-experimental-feature SafeInteropWrappers %t/method.swift -dump-macro-expansions -typecheck -verify
7+
8+
// REQUIRES: objc_interop
9+
10+
//--- Inputs/module.modulemap
11+
module Method {
12+
header "method.h"
13+
}
14+
15+
//--- Inputs/method.h
16+
17+
@interface Image
18+
19+
@property int width;
20+
21+
@end
22+
23+
//--- method.swift
24+
import Method
25+
26+
func test(_ image: Image) -> Int32 {
27+
return image.width
28+
}

0 commit comments

Comments
 (0)