[all-commits] [llvm/llvm-project] 644ac2: [-Wunsafe-buffer-usage] Introduce std::array fixit...

jkorous-apple via All-commits all-commits at lists.llvm.org
Mon Feb 12 15:52:33 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 644ac2a018c9bf83c9ba256074e552ad7f1fe941
      https://github.com/llvm/llvm-project/commit/644ac2a018c9bf83c9ba256074e552ad7f1fe941
  Author: jkorous-apple <32549412+jkorous-apple at users.noreply.github.com>
  Date:   2024-02-12 (Mon, 12 Feb 2024)

  Changed paths:
    M clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Analysis/UnsafeBufferUsage.cpp
    M clang/lib/Sema/AnalysisBasedWarnings.cpp
    A clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp
    M clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
    A clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-array.cpp
    M clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp

  Log Message:
  -----------
  [-Wunsafe-buffer-usage] Introduce std::array fixits (#80084)

Array subscript on a const size array is not bounds-checked. The idiomatic
replacement is std::array which is bounds-safe in hardened mode of libc++.

This commit extends the fixit-producing machine to consider std::array as a
transformation target type and teaches it to handle the array subscript on const
size arrays with a trivial (empty) fixit.




More information about the All-commits mailing list