@@ -4309,69 +4309,57 @@ static void checkGlobalActorAttr(
4309
4309
auto isolatedAttr = decl->getAttrs ().getAttribute <IsolatedAttr>();
4310
4310
auto nonisolatedAttr = decl->getAttrs ().getAttribute <NonisolatedAttr>();
4311
4311
auto executionAttr = decl->getAttrs ().getAttribute <ExecutionAttr>();
4312
- struct NameAndRange {
4313
- StringRef name;
4314
- SourceRange range;
4315
4312
4316
- NameAndRange (StringRef _name, SourceRange _range)
4317
- : name(_name), range(_range) {}
4318
- };
4319
-
4320
- llvm::SmallVector<NameAndRange, 4 > attributes;
4313
+ llvm::SmallVector<const DeclAttribute *, 2 > attributes;
4321
4314
4322
- attributes.push_back (NameAndRange (globalActorAttr.second ->getName ().str (),
4323
- globalActorAttr.first ->getRangeWithAt ()));
4315
+ attributes.push_back (globalActorAttr.first );
4324
4316
4325
4317
if (isolatedAttr) {
4326
- attributes.push_back (NameAndRange (isolatedAttr->getAttrName (),
4327
- isolatedAttr->getRangeWithAt ()));
4318
+ attributes.push_back (isolatedAttr);
4328
4319
}
4329
4320
if (nonisolatedAttr) {
4330
- attributes.push_back (NameAndRange (nonisolatedAttr->getAttrName (),
4331
- nonisolatedAttr->getRangeWithAt ()));
4321
+ attributes.push_back (nonisolatedAttr);
4332
4322
}
4333
4323
if (executionAttr) {
4334
- attributes.push_back (NameAndRange (executionAttr->getAttrName (),
4335
- executionAttr->getRangeWithAt ()));
4324
+ attributes.push_back (executionAttr);
4336
4325
}
4337
4326
4338
4327
if (attributes.size () == 1 )
4339
4328
return ;
4340
4329
4341
4330
if (attributes.size () == 2 ) {
4342
- decl->diagnose (diag::actor_isolation_multiple_attr_2, decl,
4343
- attributes[0 ]. name , attributes[ 1 ]. name )
4344
- .highlight (attributes[0 ]. range )
4345
- .highlight (attributes[1 ]. range )
4331
+ decl->diagnose (diag::actor_isolation_multiple_attr_2, decl, attributes[ 0 ],
4332
+ attributes[1 ] )
4333
+ .highlight (attributes[0 ]-> getRangeWithAt () )
4334
+ .highlight (attributes[1 ]-> getRangeWithAt () )
4346
4335
.warnUntilSwiftVersion (6 )
4347
- .fixItRemove (attributes[1 ]. range );
4336
+ .fixItRemove (attributes[1 ]-> getRangeWithAt () );
4348
4337
return ;
4349
4338
}
4350
4339
4351
4340
if (attributes.size () == 3 ) {
4352
- decl->diagnose (diag::actor_isolation_multiple_attr_3, decl,
4353
- attributes[0 ]. name , attributes[ 1 ]. name , attributes[2 ]. name )
4354
- .highlight (attributes[0 ]. range )
4355
- .highlight (attributes[1 ]. range )
4356
- .highlight (attributes[2 ]. range )
4341
+ decl->diagnose (diag::actor_isolation_multiple_attr_3, decl, attributes[ 0 ],
4342
+ attributes[1 ] , attributes[2 ])
4343
+ .highlight (attributes[0 ]-> getRangeWithAt () )
4344
+ .highlight (attributes[1 ]-> getRangeWithAt () )
4345
+ .highlight (attributes[2 ]-> getRangeWithAt () )
4357
4346
.warnUntilSwiftVersion (6 )
4358
- .fixItRemove (attributes[1 ]. range )
4359
- .fixItRemove (attributes[2 ]. range );
4347
+ .fixItRemove (attributes[1 ]-> getRangeWithAt () )
4348
+ .fixItRemove (attributes[2 ]-> getRangeWithAt () );
4360
4349
return ;
4361
4350
}
4362
4351
4363
4352
assert (attributes.size () == 4 );
4364
- decl->diagnose (diag::actor_isolation_multiple_attr_4, decl,
4365
- attributes[0 ].name , attributes[1 ].name , attributes[2 ].name ,
4366
- attributes[3 ].name )
4367
- .highlight (attributes[0 ].range )
4368
- .highlight (attributes[1 ].range )
4369
- .highlight (attributes[2 ].range )
4370
- .highlight (attributes[3 ].range )
4353
+ decl->diagnose (diag::actor_isolation_multiple_attr_4, decl, attributes[0 ],
4354
+ attributes[1 ], attributes[2 ], attributes[3 ])
4355
+ .highlight (attributes[0 ]->getRangeWithAt ())
4356
+ .highlight (attributes[1 ]->getRangeWithAt ())
4357
+ .highlight (attributes[2 ]->getRangeWithAt ())
4358
+ .highlight (attributes[3 ]->getRangeWithAt ())
4371
4359
.warnUntilSwiftVersion (6 )
4372
- .fixItRemove (attributes[1 ]. range )
4373
- .fixItRemove (attributes[2 ]. range )
4374
- .fixItRemove (attributes[3 ]. range );
4360
+ .fixItRemove (attributes[1 ]-> getRangeWithAt () )
4361
+ .fixItRemove (attributes[2 ]-> getRangeWithAt () )
4362
+ .fixItRemove (attributes[3 ]-> getRangeWithAt () );
4375
4363
}
4376
4364
4377
4365
void AttributeChecker::visitCustomAttr (CustomAttr *attr) {
@@ -8137,10 +8125,10 @@ class ClosureAttributeChecker
8137
8125
: ctx(closure->getASTContext ()), closure(closure) { }
8138
8126
8139
8127
void visitDeclAttribute (DeclAttribute *attr) {
8140
- ctx.Diags . diagnose (
8141
- attr->getLocation (), diag::unsupported_closure_attr,
8142
- attr->isDeclModifier (), attr-> getAttrName () )
8143
- .fixItRemove (attr->getRangeWithAt ());
8128
+ ctx.Diags
8129
+ . diagnose ( attr->getLocation (), diag::unsupported_closure_attr,
8130
+ attr->isDeclModifier (), attr)
8131
+ .fixItRemove (attr->getRangeWithAt ());
8144
8132
attr->setInvalid ();
8145
8133
}
8146
8134
@@ -8236,18 +8224,10 @@ class ClosureAttributeChecker
8236
8224
}
8237
8225
8238
8226
// Otherwise, it's an error.
8239
- std::string typeName;
8240
- if (auto typeRepr = attr->getTypeRepr ()) {
8241
- llvm::raw_string_ostream out (typeName);
8242
- typeRepr->print (out);
8243
- } else {
8244
- typeName = attr->getType ().getString ();
8245
- }
8246
-
8247
- ctx.Diags .diagnose (
8248
- attr->getLocation (), diag::unsupported_closure_attr,
8249
- attr->isDeclModifier (), typeName)
8250
- .fixItRemove (attr->getRangeWithAt ());
8227
+ ctx.Diags
8228
+ .diagnose (attr->getLocation (), diag::unsupported_closure_attr,
8229
+ attr->isDeclModifier (), attr)
8230
+ .fixItRemove (attr->getRangeWithAt ());
8251
8231
attr->setInvalid ();
8252
8232
}
8253
8233
};
0 commit comments