[PATCH] D144522: [clang-tidy] Add readability-operators-representation check

Carlos Galvez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 18 10:02:33 PDT 2023


carlosgalvezp added inline comments.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability/operators-representation.rst:16
+To configure the check to enforce the traditional token representation, you can
+set the `BinaryOperators` and `OverloadedOperators` options to ``&&,||,!``,
+respectively. This will cause the check to warn on any occurrences of ``and``,
----------------
Is there any reason why this distinction is needed? The usage of the operator happens in client code - it's unlikely one would want different style depending on whether the operator is overloaded or not?

```
bool x = some_bool and some_other_bool;
bool y = some_object && some_other_object;
```


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability/operators-representation.rst:28-29
+
+Alternative Token Representation
+--------------------------------
+
----------------
Personally I find this to be a matter of style, and arguments could be found for either style. As such I don't think this check should promote the style preference of the author of the check.

It's like having a written discussion in the clang-format option `ColumnLimit` explaining why N characters is a better choice than M characters. In the end this is a decision each project should take, and the check should not have a bias towards a preferred choice.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144522/new/

https://reviews.llvm.org/D144522



More information about the cfe-commits mailing list