@@ -321,13 +321,13 @@ class AnnotatingParser {
321
321
return parseUntouchableParens ();
322
322
}
323
323
324
- bool StartsObjCMethodExpr = false ;
324
+ bool StartsObjCSelector = false ;
325
325
if (!Style.isVerilog ()) {
326
326
if (FormatToken *MaybeSel = OpeningParen.Previous ) {
327
327
// @selector( starts a selector.
328
328
if (MaybeSel->is (tok::objc_selector) && MaybeSel->Previous &&
329
329
MaybeSel->Previous ->is (tok::at)) {
330
- StartsObjCMethodExpr = true ;
330
+ StartsObjCSelector = true ;
331
331
}
332
332
}
333
333
}
@@ -451,10 +451,8 @@ class AnnotatingParser {
451
451
}
452
452
}
453
453
454
- if (StartsObjCMethodExpr) {
455
- Contexts.back ().ColonIsObjCMethodExpr = true ;
456
- OpeningParen.setType (TT_ObjCMethodExpr);
457
- }
454
+ if (StartsObjCSelector)
455
+ OpeningParen.setType (TT_ObjCSelector);
458
456
459
457
// MightBeFunctionType and ProbablyFunctionType are used for
460
458
// function pointer and reference types as well as Objective-C
@@ -513,8 +511,8 @@ class AnnotatingParser {
513
511
}
514
512
}
515
513
516
- if (StartsObjCMethodExpr ) {
517
- CurrentToken->setType (TT_ObjCMethodExpr );
514
+ if (StartsObjCSelector ) {
515
+ CurrentToken->setType (TT_ObjCSelector );
518
516
if (Contexts.back ().FirstObjCSelectorName ) {
519
517
Contexts.back ().FirstObjCSelectorName ->LongestObjCSelectorName =
520
518
Contexts.back ().LongestObjCSelectorName ;
@@ -1449,7 +1447,7 @@ class AnnotatingParser {
1449
1447
Next->Next ->is (tok::colon)))) {
1450
1448
// This handles a special macro in ObjC code where selectors including
1451
1449
// the colon are passed as macro arguments.
1452
- Tok->setType (TT_ObjCMethodExpr );
1450
+ Tok->setType (TT_ObjCSelector );
1453
1451
}
1454
1452
break ;
1455
1453
case tok::pipe:
@@ -4608,7 +4606,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
4608
4606
return false ;
4609
4607
}
4610
4608
if (Left.is (tok::colon))
4611
- return Left.isNot ( TT_ObjCMethodExpr);
4609
+ return Left.isNoneOf (TT_ObjCSelector, TT_ObjCMethodExpr);
4612
4610
if (Left.is (tok::coloncolon))
4613
4611
return false ;
4614
4612
if (Left.is (tok::less) || Right.isOneOf (tok::greater, tok::less)) {
@@ -5464,7 +5462,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
5464
5462
// `private:` and `public:`.
5465
5463
if (!Right.getNextNonComment ())
5466
5464
return false ;
5467
- if (Right.is ( TT_ObjCMethodExpr))
5465
+ if (Right.isOneOf (TT_ObjCSelector, TT_ObjCMethodExpr))
5468
5466
return false ;
5469
5467
if (Left.is (tok::question))
5470
5468
return false ;
@@ -6288,6 +6286,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
6288
6286
return Style.BreakInheritanceList == FormatStyle::BILS_AfterColon;
6289
6287
if (Right.is (TT_InheritanceColon))
6290
6288
return Style.BreakInheritanceList != FormatStyle::BILS_AfterColon;
6289
+ // When the method parameter has no name, allow breaking before the colon.
6291
6290
if (Right.is (TT_ObjCMethodExpr) && Right.isNot (tok::r_square) &&
6292
6291
Left.isNot (TT_SelectorName)) {
6293
6292
return true ;
0 commit comments