@@ -284,21 +284,17 @@ emitApplyOfInitAccessor(SILGenFunction &SGF, SILLocation loc,
284
284
};
285
285
286
286
// First, let's emit all of the indirect results.
287
- if (auto *initAttr = accessor->getAttrs().getAttribute<InitializesAttr>()) {
288
- for (auto *property : initAttr->getPropertyDecls(accessor)) {
289
- arguments.push_back(emitFieldReference(property, /*forInit=*/true));
290
- }
287
+ for (auto *property : accessor->getInitializedProperties()) {
288
+ arguments.push_back(emitFieldReference(property, /*forInit=*/true));
291
289
}
292
290
293
291
// `initialValue`
294
292
std::move(initialValue).forwardAll(SGF, arguments);
295
293
296
- // And finally, all of the properties in `accesses(...) ` list which are
294
+ // And finally, all of the properties in `accesses` list which are
297
295
// `inout` arguments.
298
- if (auto *accessAttr = accessor->getAttrs().getAttribute<AccessesAttr>()) {
299
- for (auto *property : accessAttr->getPropertyDecls(accessor)) {
300
- arguments.push_back(emitFieldReference(property));
301
- }
296
+ for (auto *property : accessor->getAccessedProperties()) {
297
+ arguments.push_back(emitFieldReference(property));
302
298
}
303
299
304
300
SubstitutionMap subs;
@@ -1603,39 +1599,33 @@ void SILGenFunction::emitInitAccessor(AccessorDecl *accessor) {
1603
1599
InitAccessorArgumentMappings[property] = arg;
1604
1600
};
1605
1601
1606
- // First, emit results, this is our "initializes(...) " properties and
1602
+ // First, emit results, this is our "initializes" properties and
1607
1603
// require DI to check that each property is fully initialized.
1608
- if (auto *initAttr = accessor->getAttrs().getAttribute<InitializesAttr>()) {
1609
- auto initializedProperties = initAttr->getPropertyDecls(accessor);
1610
- for (unsigned i = 0, n = initializedProperties.size(); i != n; ++i) {
1611
- auto *property = initializedProperties[i];
1612
- auto propertyTy =
1613
- getSILTypeInContext(accessorTy->getResults()[i], accessorTy);
1614
- createArgument(property, propertyTy, /*markUninitialized=*/true);
1615
- }
1604
+ auto initializedProperties = accessor->getInitializedProperties();
1605
+ for (unsigned i = 0, n = initializedProperties.size(); i != n; ++i) {
1606
+ auto *property = initializedProperties[i];
1607
+ auto propertyTy =
1608
+ getSILTypeInContext(accessorTy->getResults()[i], accessorTy);
1609
+ createArgument(property, propertyTy, /*markUninitialized=*/true);
1616
1610
}
1617
1611
1618
1612
// Collect all of the parameters that represent properties listed by
1619
1613
// "accesses" attribute. They have to be emitted in order of arguments which
1620
1614
// means after the "newValue" which is emitted by \c emitBasicProlog.
1621
- llvm::Optional<ArrayRef<VarDecl *>> accessedProperties;
1622
- {
1623
- if (auto *accessAttr = accessor->getAttrs().getAttribute<AccessesAttr>())
1624
- accessedProperties = accessAttr->getPropertyDecls(accessor);
1625
- }
1615
+ auto accessedProperties = accessor->getAccessedProperties();
1626
1616
1627
1617
// Emit `newValue` argument.
1628
1618
emitBasicProlog(accessor->getParameters(), /*selfParam=*/nullptr,
1629
1619
TupleType::getEmpty(F.getASTContext()), accessor,
1630
1620
/*throws=*/false, /*throwsLoc=*/SourceLoc(),
1631
1621
/*ignored parameters*/
1632
- accessedProperties ? accessedProperties-> size() : 0 );
1622
+ accessedProperties. size());
1633
1623
1634
- // Emit arguments for all `accesses(...) ` properties.
1635
- if (accessedProperties) {
1636
- auto propertyIter = accessedProperties-> begin();
1624
+ // Emit arguments for all `accesses` properties.
1625
+ if (! accessedProperties.empty() ) {
1626
+ auto propertyIter = accessedProperties. begin();
1637
1627
auto propertyArgs = accessorTy->getParameters().slice(
1638
- accessorTy->getNumParameters() - accessedProperties-> size());
1628
+ accessorTy->getNumParameters() - accessedProperties. size());
1639
1629
1640
1630
for (const auto &argument : propertyArgs) {
1641
1631
createArgument(*propertyIter, getSILTypeInContext(argument, accessorTy));
0 commit comments