@@ -1602,8 +1602,9 @@ static ObjCSelector inferObjCName(ValueDecl *decl) {
1602
1602
1603
1603
auto attr = decl->getAttrs ().getAttribute <ObjCAttr>();
1604
1604
1605
- // / Set the @objc name.
1606
1605
ASTContext &ctx = decl->getASTContext ();
1606
+
1607
+ // / Set the @objc name.
1607
1608
auto setObjCName = [&](ObjCSelector selector) {
1608
1609
// If there already is an @objc attribute, update its name.
1609
1610
if (attr) {
@@ -1627,13 +1628,18 @@ static ObjCSelector inferObjCName(ValueDecl *decl) {
1627
1628
// Determine whether there is a name conflict.
1628
1629
bool shouldFixName = !attr || !attr->hasName ();
1629
1630
if (attr && attr->hasName () && *attr->getName () != overriddenSelector) {
1631
+ auto reason = objCReasonForObjCAttr (attr);
1632
+ auto behavior = behaviorLimitForObjCReason (reason, ctx);
1633
+
1630
1634
// If the user explicitly wrote the incorrect name, complain.
1631
1635
if (!attr->isNameImplicit ()) {
1632
1636
{
1633
- auto diag = ctx.Diags .diagnose (
1634
- attr->AtLoc ,
1635
- diag::objc_override_method_selector_mismatch,
1636
- *attr->getName (), overriddenSelector);
1637
+ auto diag = std::move (
1638
+ ctx.Diags .diagnose (
1639
+ attr->AtLoc ,
1640
+ diag::objc_override_method_selector_mismatch,
1641
+ *attr->getName (), overriddenSelector)
1642
+ .limitBehavior (behavior));
1637
1643
fixDeclarationObjCName (diag, decl, attr->getName (),
1638
1644
overriddenSelector);
1639
1645
}
@@ -1661,6 +1667,9 @@ static ObjCSelector inferObjCName(ValueDecl *decl) {
1661
1667
bool shouldFixName = !attr || !attr->hasName ();
1662
1668
if (attr && attr->hasName () &&
1663
1669
*attr->getName () != overriddenNameAsSel) {
1670
+ auto reason = objCReasonForObjCAttr (attr);
1671
+ auto behavior = behaviorLimitForObjCReason (reason, ctx);
1672
+
1664
1673
// If the user explicitly wrote the wrong name, complain.
1665
1674
if (!attr->isNameImplicit ()) {
1666
1675
SourceLoc diagLoc = attr->AtLoc , firstNameLoc;
@@ -1674,7 +1683,8 @@ static ObjCSelector inferObjCName(ValueDecl *decl) {
1674
1683
overriddenName)
1675
1684
.fixItReplaceChars (firstNameLoc,
1676
1685
attr->getRParenLoc (),
1677
- overriddenName.str ());
1686
+ overriddenName.str ())
1687
+ .limitBehavior (behavior);
1678
1688
overridden->diagnose (diag::overridden_here);
1679
1689
}
1680
1690
0 commit comments