@@ -4309,69 +4309,57 @@ static void checkGlobalActorAttr(
43094309 auto isolatedAttr = decl->getAttrs ().getAttribute <IsolatedAttr>();
43104310 auto nonisolatedAttr = decl->getAttrs ().getAttribute <NonisolatedAttr>();
43114311 auto executionAttr = decl->getAttrs ().getAttribute <ExecutionAttr>();
4312- struct NameAndRange {
4313- StringRef name;
4314- SourceRange range;
43154312
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;
43214314
4322- attributes.push_back (NameAndRange (globalActorAttr.second ->getName ().str (),
4323- globalActorAttr.first ->getRangeWithAt ()));
4315+ attributes.push_back (globalActorAttr.first );
43244316
43254317 if (isolatedAttr) {
4326- attributes.push_back (NameAndRange (isolatedAttr->getAttrName (),
4327- isolatedAttr->getRangeWithAt ()));
4318+ attributes.push_back (isolatedAttr);
43284319 }
43294320 if (nonisolatedAttr) {
4330- attributes.push_back (NameAndRange (nonisolatedAttr->getAttrName (),
4331- nonisolatedAttr->getRangeWithAt ()));
4321+ attributes.push_back (nonisolatedAttr);
43324322 }
43334323 if (executionAttr) {
4334- attributes.push_back (NameAndRange (executionAttr->getAttrName (),
4335- executionAttr->getRangeWithAt ()));
4324+ attributes.push_back (executionAttr);
43364325 }
43374326
43384327 if (attributes.size () == 1 )
43394328 return ;
43404329
43414330 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 () )
43464335 .warnUntilSwiftVersion (6 )
4347- .fixItRemove (attributes[1 ]. range );
4336+ .fixItRemove (attributes[1 ]-> getRangeWithAt () );
43484337 return ;
43494338 }
43504339
43514340 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 () )
43574346 .warnUntilSwiftVersion (6 )
4358- .fixItRemove (attributes[1 ]. range )
4359- .fixItRemove (attributes[2 ]. range );
4347+ .fixItRemove (attributes[1 ]-> getRangeWithAt () )
4348+ .fixItRemove (attributes[2 ]-> getRangeWithAt () );
43604349 return ;
43614350 }
43624351
43634352 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 ())
43714359 .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 () );
43754363}
43764364
43774365void AttributeChecker::visitCustomAttr (CustomAttr *attr) {
@@ -8137,10 +8125,10 @@ class ClosureAttributeChecker
81378125 : ctx(closure->getASTContext ()), closure(closure) { }
81388126
81398127 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 ());
81448132 attr->setInvalid ();
81458133 }
81468134
@@ -8236,18 +8224,10 @@ class ClosureAttributeChecker
82368224 }
82378225
82388226 // 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 ());
82518231 attr->setInvalid ();
82528232 }
82538233};
0 commit comments