@@ -2177,14 +2177,21 @@ class AnnotatingParser {
2177
2177
2178
2178
if (PrevToken->Tok .isLiteral () ||
2179
2179
PrevToken->isOneOf (tok::r_paren, tok::r_square, tok::kw_true,
2180
- tok::kw_false, tok::r_brace) ||
2181
- NextToken->Tok .isLiteral () ||
2182
- NextToken->isOneOf (tok::kw_true, tok::kw_false) ||
2183
- NextToken->isUnaryOperator () ||
2184
- // If we know we're in a template argument, there are no named
2185
- // declarations. Thus, having an identifier on the right-hand side
2186
- // indicates a binary operator.
2187
- (InTemplateArgument && NextToken->Tok .isAnyIdentifier ()))
2180
+ tok::kw_false, tok::r_brace))
2181
+ return TT_BinaryOperator;
2182
+
2183
+ const FormatToken *NextNonParen = NextToken;
2184
+ while (NextNonParen && NextNonParen->is (tok::l_paren))
2185
+ NextNonParen = NextNonParen->getNextNonComment ();
2186
+ if (NextNonParen && (NextNonParen->Tok .isLiteral () ||
2187
+ NextNonParen->isOneOf (tok::kw_true, tok::kw_false) ||
2188
+ NextNonParen->isUnaryOperator ()))
2189
+ return TT_BinaryOperator;
2190
+
2191
+ // If we know we're in a template argument, there are no named declarations.
2192
+ // Thus, having an identifier on the right-hand side indicates a binary
2193
+ // operator.
2194
+ if (InTemplateArgument && NextToken->Tok .isAnyIdentifier ())
2188
2195
return TT_BinaryOperator;
2189
2196
2190
2197
// "&&(" is quite unlikely to be two successive unary "&".
@@ -4508,12 +4515,11 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
4508
4515
4509
4516
// We only break before r_paren if we're in a block indented context.
4510
4517
if (Right.is (tok::r_paren)) {
4511
- if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
4518
+ if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent)
4512
4519
return Right.MatchingParen &&
4513
4520
!(Right.MatchingParen ->Previous &&
4514
4521
(Right.MatchingParen ->Previous ->is (tok::kw_for) ||
4515
4522
Right.MatchingParen ->Previous ->isIf ()));
4516
- }
4517
4523
4518
4524
return false ;
4519
4525
}
0 commit comments