@@ -501,21 +501,18 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
501
501
SILType::getPrimitiveObjectType (mainClassMetaty));
502
502
metaTy = B.createInitExistentialMetatype (mainClass, metaTy,
503
503
SILType::getPrimitiveObjectType (anyObjectMetaTy), {});
504
- SILValue optName = B.createApply (mainClass,
505
- NSStringFromClass,
506
- NSStringFromClass->getType (),
507
- SILType::getPrimitiveObjectType (OptNSStringTy),
508
- {}, metaTy);
504
+ SILValue optNameValue = B.createApply (
505
+ mainClass, NSStringFromClass, NSStringFromClass->getType (),
506
+ SILType::getPrimitiveObjectType (OptNSStringTy), {}, metaTy);
507
+ ManagedValue optName = emitManagedRValueWithCleanup (optNameValue);
509
508
510
509
// Fix up the string parameters to have the right type.
511
510
SILType nameArgTy = fnConv.getSILArgumentType (3 );
512
511
assert (nameArgTy == fnConv.getSILArgumentType (2 ));
513
512
(void )nameArgTy;
514
- auto managedName = ManagedValue::forUnmanaged (optName);
515
- SILValue nilValue;
516
- assert (optName->getType () == nameArgTy);
517
- nilValue = getOptionalNoneValue (mainClass,
518
- getTypeLowering (OptNSStringTy));
513
+ assert (optName.getType () == nameArgTy);
514
+ SILValue nilValue =
515
+ getOptionalNoneValue (mainClass, getTypeLowering (OptNSStringTy));
519
516
520
517
// Fix up argv to have the right type.
521
518
auto argvTy = fnConv.getSILArgumentType (1 );
@@ -544,7 +541,7 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
544
541
auto UIApplicationMain = B.createFunctionRef (mainClass, UIApplicationMainFn);
545
542
546
543
SILValue args[] = {argc, managedArgv.getValue (), nilValue,
547
- managedName .getValue ()};
544
+ optName .getValue ()};
548
545
549
546
B.createApply (mainClass, UIApplicationMain,
550
547
UIApplicationMain->getType (),
0 commit comments