Skip to content

Commit 448a6ce

Browse files
committed
Outliner: Check that we have a self argument before we ask for it
rdar://57849479
1 parent aeea84d commit 448a6ce

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

lib/SILOptimizer/Transforms/Outliner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,8 @@ BridgedArgument BridgedArgument::match(unsigned ArgIdx, SILValue Arg,
762762
auto *BridgeCall =
763763
dyn_cast<ApplyInst>(std::prev(SILBasicBlock::iterator(Enum)));
764764
if (!BridgeCall || BridgeCall->getNumArguments() != 1 ||
765-
Enum->getOperand() != BridgeCall || !BridgeCall->hasOneUse())
765+
Enum->getOperand() != BridgeCall || !BridgeCall->hasOneUse() ||
766+
!FullApplySite(BridgeCall).hasSelfArgument())
766767
return BridgedArgument();
767768

768769
auto &selfArg = FullApplySite(BridgeCall).getSelfArgumentOperand();

test/SILOptimizer/Inputs/Outliner.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,9 @@ NS_ASSUME_NONNULL_BEGIN
6060
- (nullable NSArray *) treeishChildren;
6161
@end
6262
NS_ASSUME_NONNULL_END
63+
64+
NS_ASSUME_NONNULL_BEGIN
65+
@interface MyObject : NSObject
66+
@property (nullable) NSError *error;
67+
@end
68+
NS_ASSUME_NONNULL_END

test/SILOptimizer/outliner.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,20 @@ open class Test
239239
return view
240240
}
241241
}
242+
243+
internal extension NSError {
244+
convenience init(myError code: Int) {
245+
self.init(domain: "error", code: code, userInfo: [:])
246+
}
247+
}
248+
249+
public class AnotherTest {
250+
public let obj: MyObject
251+
public init(obj: MyObject) {
252+
self.obj = obj
253+
}
254+
255+
public func dontCrash() {
256+
self.obj.error = NSError(myError: 10)
257+
}
258+
}

0 commit comments

Comments
 (0)