[clang-tools-extra] [clang-tidy] Create a check for signed and unsigned integers comparison (PR #113144)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 21 16:41:40 PST 2024
================
@@ -0,0 +1,34 @@
+.. title:: clang-tidy - modernize-use-integer-sign-comparison
+
+modernize-use-integer-sign-comparison
+=====================================
+
+Replace comparisons between signed and unsigned integers with their safe
+C++20 ``std::cmp_*`` alternative, if available.
+
+
+Examples of fixes created by the check:
+
+.. code-block:: c++
+
+ uint func(int a, uint b) {
+ return a == b;
+ }
+
+becomes
+
+.. code-block:: c++
+
+ #include <utility>
+
+ uint func(int a, uint b) {
+ return (std::cmp_equal(result, bla))
----------------
5chmidti wrote:
This is missing a semicolon at the end, and the outer parens are not actually added by the check
https://github.com/llvm/llvm-project/pull/113144
More information about the cfe-commits
mailing list