[all-commits] [llvm/llvm-project] 7122f5: [-Wunsafe-buffer-usage] Warning for unsafe invocat...

Malavika Samak via All-commits all-commits at lists.llvm.org
Tue Jan 2 15:41:14 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7122f55c639a00e719b6088249f4fca1810cf04c
      https://github.com/llvm/llvm-project/commit/7122f55c639a00e719b6088249f4fca1810cf04c
  Author: Malavika Samak <malavika.samak at gmail.com>
  Date:   2024-01-02 (Tue, 02 Jan 2024)

  Changed paths:
    M clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
    M clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
    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-warning-data-invocation.cpp

  Log Message:
  -----------
  [-Wunsafe-buffer-usage] Warning for unsafe invocation of span::data (#75650)

…-Wunsafe-buffer-usage,

there maybe accidental re-introduction of new OutOfBound accesses into
the code bases. One such case is invoking span::data() method on a span
variable to retrieve a pointer, which is then cast to a larger type and
dereferenced. Such dereferences can introduce OutOfBound accesses.

To address this, a new WarningGadget is being introduced to warn against
such invocations.

---------

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




More information about the All-commits mailing list