[clang-tools-extra] [clang-tidy] Add new check `readability-use-numeric-limits` (PR #127430)

Katherine Whitlock via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 18 08:32:50 PST 2025


================
@@ -0,0 +1,23 @@
+.. title:: clang-tidy - readability-use-numeric-limits
+
+readability-use-numeric-limits
+==============================
+
+ Replaces certain integer literals with equivalent calls to
+ ``std::numeric_limits<T>::min()`` or ``std::numeric_limits<T>::max()``.
+
+Before:
+
+.. code-block:: c++
+
+  void foo() {
+    int32_t a = 2147483647;
+  }
+
+After:
+
+.. code-block:: c++
+
+  void foo() {
+    int32_t a = std::numeric_limits<int32_t>::max();
+  }
----------------
stellar-aria wrote:

Added below, matching `modernize/replace-auto-ptr.rst`, and added the relevant `storeOptions` override to the check.

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


More information about the cfe-commits mailing list