[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 13 00:16:56 PDT 2025


================
@@ -316,3 +316,11 @@ Options
    When `true`, the check will warn on pointer arithmetic where the
    element count is obtained from a division with ``sizeof(...)``,
    e.g., ``Ptr + Bytes / sizeof(*T)``. Default is `true`.
+
+.. option:: WarnOnSizeOfInLoopTermination
+
+   When `true`, the check will warn about incorrect use of sizeof expression
+   in loop termination condition. The warning triggers if the sizeof expression
+   appears to be incorrectly used to determine the number of array/buffer elements.
----------------
vbvictor wrote:

Please follow 80-character limit

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


More information about the cfe-commits mailing list