[PATCH] D153059: [-Wunsafe-buffer-usage][WIP] Group parameter fix-its

Ziqing Luo via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 15 13:10:51 PDT 2023


ziqingluo-90 added inline comments.


================
Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2085
       continue;
     }
     for (const auto &F : Fixables) {
----------------
I changed the rest of this function drastically so let me explain what I did.

The table `FixItsForVariable` is initiated with variables whose declarations and associated `Fixable`s can be fixed.  So if a variable is not in the table,  either 1) its declaration cannot be fixed or 2) one of its `Fixable`s cannot be fixed.   Then, the table is further reduced by removing elements such that at least one of its' group members satisfies 1) or 2).
Eventually, the table  `FixItsForVariable` can be used to determine if a variable is `ImpossibleToFix` (so we no longer need this flag).   `FixItsForVariable[V]`, if `V` exists there,  is a collection of fix-its for `V`'s declaration and all `Fixable`s associated to `V`.

With parameters being fixed, we also generate function overloads as fix-its for the parameters.  These overload fix-its are "shared" by the parameters.  It means that these fix-its will be added for the group where the parameters belong to, instead of being added to `FixItsForVariable[PV]` for each such parameter `PV`.

So finally, for a variable `V`, `FinalFixItsForVariable[V]` is a collection of fix-its for the whole group where `V` is at. 




================
Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2264
+  // variable `x` implicates fixing `y`:
   DepMapTy PtrAssignmentGraph{};
+
----------------
How about changing the variable name to `PtrImplicationGraph`?  For two variables `V` and `W`,  if `W` is in `PtrImplicationGraph[V]`, it means fixing `V` implicates fixing `W`, right?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153059/new/

https://reviews.llvm.org/D153059



More information about the cfe-commits mailing list