[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:52 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.
+
----------------
PiotrZSL wrote:

Consider adding some longer description, like rationale, for example:

_Parentheses in mathematical expressions clarify the order of operations, especially with different-priority operators. Lengthy or multiline expressions can obscure this order, leading to coding errors. IDEs can aid clarity by highlighting parentheses. Explicitly using parentheses also clarify what the developer had in mind when writing the expression. Ensuring their presence reduces ambiguity and errors, promoting clearer and more maintainable code._


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


More information about the cfe-commits mailing list