[all-commits] [llvm/llvm-project] 0d00a9: [-Wunsafe-buffer-usage] NFC: Introduce an abstract...

NoQ via All-commits all-commits at lists.llvm.org
Fri Dec 16 15:02:49 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0d00a9722f3ce9d314ddd26a33e22921956b7519
      https://github.com/llvm/llvm-project/commit/0d00a9722f3ce9d314ddd26a33e22921956b7519
  Author: Artem Dergachev <adergachev at apple.com>
  Date:   2022-12-16 (Fri, 16 Dec 2022)

  Changed paths:
    A clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
    M clang/lib/Analysis/UnsafeBufferUsage.cpp

  Log Message:
  -----------
  [-Wunsafe-buffer-usage] NFC: Introduce an abstraction for fixable code patterns.

This patch introduces a hierarchy of Gadget classes, which are going to be
the core concept in the somewhat sophisticated machine behind the upcoming
-Wunsafe-buffer-usage fix-it hints.

A gadget is a rigid code pattern that constitutes an operation that
the fixit machine "understands" well enough to work with. A gadget may be
"unsafe" (i.e., constitute a raw buffer access) or "safe" (constitute
a use of a pointer or array variable that isn't unsafe per se,
but may need fixing if the participating variable changes type
to a safe container/view).

We'll be able to make decisions about how to fix the code depending on
the set of gadgets that we've enumerated. Basically, in order to fix a type
of a variable, each use of that variable has to participate in a gadget,
and each such gadget has to consent to fixing itself according to
the variable's new type.

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




More information about the All-commits mailing list