Skip to content

Commit 27e7bd8

Browse files
committed
[SILGen] Remove one more inlined copy of VarDecl::isMemberwiseInitialized().
1 parent f863700 commit 27e7bd8

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

lib/SILGen/SILGenConstructor.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -177,32 +177,31 @@ static void emitImplicitValueConstructor(SILGenFunction &SGF,
177177
fieldTy.getAddressType());
178178
InitializationPtr init(new KnownAddressInitialization(slot));
179179

180-
// An initialized 'let' property has a single value specified by the
181-
// initializer - it doesn't come from an argument.
182-
if (!field->isStatic() && field->isLet() &&
183-
field->getParentInitializer()) {
180+
// If it's memberwise initialized, do so now.
181+
if (field->isMemberwiseInitialized(/*preferDeclaredProperties=*/false)) {
182+
assert(elti != eltEnd &&
183+
"number of args does not match number of fields");
184+
(void)eltEnd;
185+
FullExpr scope(SGF.Cleanups, field->getParentPatternBinding());
186+
if (!maybeEmitPropertyDelegateInitFromValue(
187+
SGF, Loc, field, std::move(*elti),
188+
[&](Expr *expr) {
189+
SGF.emitExprInto(expr, init.get());
190+
})) {
191+
std::move(*elti).forwardInto(SGF, Loc, init.get());
192+
}
193+
++elti;
194+
} else {
184195
#ifndef NDEBUG
185-
assert(field->getType()->isEqual(field->getParentInitializer()->getType())
186-
&& "Checked by sema");
196+
assert(
197+
field->getType()->isEqual(field->getParentInitializer()->getType())
198+
&& "Checked by sema");
187199
#endif
188200

189201
// Cleanup after this initialization.
190202
FullExpr scope(SGF.Cleanups, field->getParentPatternBinding());
191203
SGF.emitExprInto(field->getParentInitializer(), init.get());
192-
continue;
193204
}
194-
195-
assert(elti != eltEnd && "number of args does not match number of fields");
196-
(void)eltEnd;
197-
FullExpr scope(SGF.Cleanups, field->getParentPatternBinding());
198-
if (!maybeEmitPropertyDelegateInitFromValue(
199-
SGF, Loc, field, std::move(*elti),
200-
[&](Expr *expr) {
201-
SGF.emitExprInto(expr, init.get());
202-
})) {
203-
std::move(*elti).forwardInto(SGF, Loc, init.get());
204-
}
205-
++elti;
206205
}
207206
SGF.B.createReturn(ImplicitReturnLocation::getImplicitReturnLoc(Loc),
208207
SGF.emitEmptyTuple(Loc));

0 commit comments

Comments
 (0)