[all-commits] [llvm/llvm-project] 634130: [-Wunsafe-buffer-usage] Improve fix-its for local ...

Ziqing Luo via All-commits all-commits at lists.llvm.org
Mon Apr 10 12:09:25 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 63413015099bc8aaa45cba7551e8fe432b2b795f
      https://github.com/llvm/llvm-project/commit/63413015099bc8aaa45cba7551e8fe432b2b795f
  Author: ziqingluo-90 <ziqing at udel.edu>
  Date:   2023-04-10 (Mon, 10 Apr 2023)

  Changed paths:
    M clang/lib/Analysis/UnsafeBufferUsage.cpp
    M clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp

  Log Message:
  -----------
  [-Wunsafe-buffer-usage] Improve fix-its for local variable declarations with null pointer initializers

For a local pointer declaration of the form `T * p = 0` or `T * p = std::nullptr`,

Before this patch, we generate fix-its that convert the declaration to
`std::span<T> p{nullptr, <# placeholder #>}`, in cases where `p` is
used in some unsafe operations.  This patch improves the fix-its to
result in a simpler form `std::span<T> p`. It gets rid of the
placeholder and keeps the result concise.

Reviewed by: NoQ (Artem Dergachev)

Differential Revision: https://reviews.llvm.org/D143680




More information about the All-commits mailing list