Skip to content

Commit 84c93c9

Browse files
authored
Merge pull request #20150 from gottesmm/pr-26e198ff9ce5988a7c8c4892ac2a900473b1b7a1
[silgen] Add a missing destroy_value in our code that emits UIApplica…
2 parents ba15147 + e96dcdf commit 84c93c9

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

lib/SILGen/SILGenFunction.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -501,21 +501,18 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
501501
SILType::getPrimitiveObjectType(mainClassMetaty));
502502
metaTy = B.createInitExistentialMetatype(mainClass, metaTy,
503503
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);
509508

510509
// Fix up the string parameters to have the right type.
511510
SILType nameArgTy = fnConv.getSILArgumentType(3);
512511
assert(nameArgTy == fnConv.getSILArgumentType(2));
513512
(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));
519516

520517
// Fix up argv to have the right type.
521518
auto argvTy = fnConv.getSILArgumentType(1);
@@ -544,7 +541,7 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
544541
auto UIApplicationMain = B.createFunctionRef(mainClass, UIApplicationMainFn);
545542

546543
SILValue args[] = {argc, managedArgv.getValue(), nilValue,
547-
managedName.getValue()};
544+
optName.getValue()};
548545

549546
B.createApply(mainClass, UIApplicationMain,
550547
UIApplicationMain->getType(),

0 commit comments

Comments
 (0)