[PATCH] D156188: Refactor and improve for parameter fix-its

Ziqing Luo via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 24 17:06:19 PDT 2023


ziqingluo-90 created this revision.
ziqingluo-90 added reviewers: NoQ, jkorous, t-rasmud, malavikasamak.
Herald added a project: All.
ziqingluo-90 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Factor out the code that will be shared by both parameter and local variable fix-its

- Add a check to ensure that a `TypeLoc::isNull` is false before using the `TypeLoc`

- Remove the special check for whether a fixing variable involves unnamed types.  This check is unnecessary now.  Because we will give up on fixing a pointer type variable `v`, if we cannot obtain the source range of the pointee type of `v`.  Using unnamed types is just one of the many causes of such scenarios.  Besides, in some cases, we have no problem in referring to unnamed types.  Therefore, we remove the special handling since we have a more general solution already.

For example,

  typedef struct {int x;} UNNAMED_T;
  
  UNNAMED_T * x; //  we can refer to the unnamed struct using `UNNAMED_T`
  
  typedef struct {int x;} * UNNAMED_PTR;
  
  UNNAMED_PTR y; // we cannot obtain the source range of the pointee type of `y`,	so we will give up



- Move tests for cv-qualified parameters and unnamed types out of the "...-unsupported.cpp" test file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156188

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-unsupported.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156188.543739.patch
Type: text/x-patch
Size: 17824 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230725/dda4cd6d/attachment-0001.bin>


More information about the cfe-commits mailing list