[all-commits] [llvm/llvm-project] 6a0f2e: [-Wunsafe-buffer-usage] Add Fixable for dereferenc...

Ziqing Luo via All-commits all-commits at lists.llvm.org
Mon Mar 20 17:07:26 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6a0f2e539b8ef1f510f62aceb36430b95e40f0d3
  Author: ziqingluo-90 <ziqing at udel.edu>
  Date:   2023-03-20 (Mon, 20 Mar 2023)

  Changed paths:
    M clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
    M clang/lib/Analysis/UnsafeBufferUsage.cpp
    A clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-deref-simple-ptr-arith.cpp

  Log Message:
  [-Wunsafe-buffer-usage] Add Fixable for dereference of simple ptr arithmetic

For each expression `e` of the form `*(DRE + n)` (or `*(n + DRE)`), where
`DRE` has a pointer type and `n` is an integer literal, `e` will be
transformed to `DRE[n]` (or `n[DRE]` respectively), if
- `e` is at the left-hand side of an assignment or is an lvalue being casted to an rvalue; and
- the variable referred by `DRE` is going to be transformed to be of `std::span` type.

Reviewed by: jkorous, NoQ

Differential revision: https://reviews.llvm.org/D142795

More information about the All-commits mailing list