Skip to content

Commit b5985e0

Browse files
Merge pull request #28744 from aschwaighofer/outliner_fix_57849479
Outliner: Check that we have a self argument before we ask for it
2 parents cc8f8e9 + 448a6ce commit b5985e0

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
@@ -764,7 +764,8 @@ BridgedArgument BridgedArgument::match(unsigned ArgIdx, SILValue Arg,
764764
auto *BridgeCall =
765765
dyn_cast<ApplyInst>(std::prev(SILBasicBlock::iterator(Enum)));
766766
if (!BridgeCall || BridgeCall->getNumArguments() != 1 ||
767-
Enum->getOperand() != BridgeCall || !BridgeCall->hasOneUse())
767+
Enum->getOperand() != BridgeCall || !BridgeCall->hasOneUse() ||
768+
!FullApplySite(BridgeCall).hasSelfArgument())
768769
return BridgedArgument();
769770

770771
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)