Outliner: Verify that getBridgeFromObjectiveC and getBridgeToObjectiveC return a valid SILDeclRef (#28703)

rdar://57757241
This commit is contained in:
Arnold Schwaighofer 2019-12-11 10:45:25 -08:00 коммит произвёл Ben Cohen
Родитель a108d969cf
Коммит d513cc97c8
3 изменённых файлов: 22 добавлений и 2 удалений

Просмотреть файл

@ -492,7 +492,8 @@ static bool matchSwitch(SwitchInfo &SI, SILInstruction *Inst,
auto *BridgeFun = FunRef->getInitiallyReferencedFunction();
auto *SwiftModule = BridgeFun->getModule().getSwiftModule();
auto bridgeWitness = getBridgeFromObjectiveC(NativeType, SwiftModule);
if (BridgeFun->getName() != bridgeWitness.mangle())
if (bridgeWitness == SILDeclRef() ||
BridgeFun->getName() != bridgeWitness.mangle())
return false;
// %41 = enum $Optional<String>, #Optional.some!enumelt.1, %40 : $String
@ -809,7 +810,8 @@ BridgedArgument BridgedArgument::match(unsigned ArgIdx, SILValue Arg,
auto *BridgeFun = FunRef->getInitiallyReferencedFunction();
auto *SwiftModule = BridgeFun->getModule().getSwiftModule();
auto bridgeWitness = getBridgeToObjectiveC(NativeType, SwiftModule);
if (BridgeFun->getName() != bridgeWitness.mangle())
if (bridgeWitness == SILDeclRef() ||
BridgeFun->getName() != bridgeWitness.mangle())
return BridgedArgument();
return BridgedArgument(ArgIdx, FunRef, BridgeCall, Enum, BridgedValueRelease,

Просмотреть файл

@ -34,6 +34,7 @@ typedef NS_ENUM(NSUInteger, MyEventType) {
@interface MyView : NSObject
@property (nonatomic, nullable, readonly, strong) MyWindow *window;
@property (nonatomic, nullable, strong) MyWindow *window2;
@end
typedef struct MyPoint {

Просмотреть файл

@ -222,3 +222,20 @@ public func testCalendar() {
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .gregorian)
}
open class Test
{
@inline(never)
public func getWindow() -> MyWindow
{
return MyWindow()
}
public func testDontCrash() -> MyView
{
let view = MyView()
view.window2 = getWindow()
return view
}
}