[all-commits] [llvm/llvm-project] 6d34cf: [Sema] Diagnose tautological bounds checks (#120222)

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Dec 17 19:39:34 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6d34cfac53b993a6cdf3d6669e017eac3a2296c8
      https://github.com/llvm/llvm-project/commit/6d34cfac53b993a6cdf3d6669e017eac3a2296c8
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2024-12-18 (Wed, 18 Dec 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/SemaExpr.cpp
    A clang/test/Sema/tautological-pointer-comparison.c

  Log Message:
  -----------
  [Sema] Diagnose tautological bounds checks (#120222)

This diagnoses comparisons like `ptr + unsigned_index < ptr` and `ptr +
unsigned_index >= ptr`, which are always false/true because addition of
a pointer and an unsigned index cannot wrap (or the behavior is
undefined).

This warning is intended to help find broken bounds checks (which must
be implemented in terms of uintptr_t instead).

Fixes https://github.com/llvm/llvm-project/issues/120214.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list