[clang-tools-extra] Add clang-tidy check readability-math-missing-parentheses (PR #84481)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 19 11:54:51 PDT 2024


================
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - readability-math-missing-parentheses
+
+readability-math-missing-parentheses
+====================================
+
+Check for mising parantheses in mathematical expressions that involve operators
+of different priorities.
+
+Before:
+
+.. code-block:: c++
+
+  int x = 1 + 2 * 3 - 4 / 5;
+
+
+After:
+
+.. code-block:: c++
+
+  int x = (1 + (2 * 3)) - (4 / 5);
----------------
PiotrZSL wrote:

target should be:
`int x = 1 + (2 * 3) - (4 / 5);`

same like in example: 1 * 2 / 3 *10 / 23, no parentheses should be inserted.

https://github.com/llvm/llvm-project/pull/84481


More information about the cfe-commits mailing list