[clang-tools-extra] [clang-tidy] Create a check for signed and unsigned integers comparison (PR #113144)

Carlos Galvez via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 9 11:01:21 PST 2024


================
@@ -0,0 +1,36 @@
+.. 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.
+
+The check provides a replacement only for C++20 or later, otherwise
+it highlights the problem and expects the user to fix it manually.
+
+Examples of fixes created by the check:
+
+.. code-block:: c++
+
+  uint func(int a, uint b) {
----------------
carlosgalvezp wrote:

"uint" is not a standard C++ type, use `unsigned int`

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


More information about the cfe-commits mailing list