[all-commits] [llvm/llvm-project] 393156: [-Wunsafe-buffer-usage] Fix false warnings when co...

Malavika Samak via All-commits all-commits at lists.llvm.org
Fri May 16 18:34:13 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 39315663a40a261772df94218fd33e205e888e54
      https://github.com/llvm/llvm-project/commit/39315663a40a261772df94218fd33e205e888e54
  Author: Malavika Samak <malavika.samak at gmail.com>
  Date:   2025-05-16 (Fri, 16 May 2025)

  Changed paths:
    M clang/lib/Analysis/UnsafeBufferUsage.cpp
    M clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp

  Log Message:
  -----------
  [-Wunsafe-buffer-usage] Fix false warnings when const sized array is safely accessed (array [idx %const]) (#140113)

The -Wunsafe-buffer-usage analysis currently warns when a const sized
array is safely accessed, with an index that is bound by the remainder
operator. The false alarm is now suppressed.

Example:

int circular_buffer(int array[10], uint idx) {
   return array[idx %10]; // Safe operation
}

rdar://148443453

---------

Co-authored-by: MalavikaSamak <malavika2 at apple.com>



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