================
@@ -2450,9 +2450,75 @@ struct FormatStyle {
BBO_RespectPrecedence
};
+ /// A rule that specifies how to break a specific set of binary operators.
+ /// \version 23
+ struct BinaryOperationBreakRule {
+ /// The list of operator tokens this rule applies to,
+ /// e.g. ``["&&", "||"]``.
+ std::vector<std::string> Operators;
----------------
ssubbotin wrote:
Great suggestion — done in commit 258f4f3. Changed `Operators` from
`std::vector<std::string>` to `std::vector<tok::TokenKind>`. This automatically
handles alternative spellings (`and` vs `&&`, `or` vs `||`, etc.) since they
map to the same `tok::TokenKind`.
YAML parsing uses a `ScalarTraits<tok::TokenKind>` that converts strings to
token kinds via the `PUNCTUATOR` macro from `TokenKinds.def`, and the lookup
uses `OpToken->Tok.getKind()`.
One additional thing this uncovered: clang-format splits `>>` into two `>`
tokens for template parsing (in `FormatTokenLexer`), so a `>>` rule in YAML
(`tok::greatergreater`) would never match the actual `tok::greater` tokens.
Fixed in commit 2882b09 by also checking `tok::greatergreater` rules when the
token is `tok::greater`.
https://github.com/llvm/llvm-project/pull/181051
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits