[PATCH] D156474: [-Wunsafe-buffer-usage][NFC] Slightly refactor and optimize the code

Rashmi Mudduluru via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 1 14:14:31 PDT 2023


t-rasmud added inline comments.


================
Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2179
+      if (FixItsForVariable.count(GrpMate))
+        FinalFixItsForVariable[Var].insert(FinalFixItsForVariable[Var].end(),
+                                           FixItsForVariable[GrpMate].begin(),
----------------
ziqingluo-90 wrote:
> Instead of calling `fixVariable` to generate fix-its for group mates, directly copying those fix-its from the `FixItsForVariable` container.
> 
> At this point,  `FixItsForVariable` is complete. That is, it maps every variable to its own fix-its (excluding fix-its of group mates).
Do you mean "including fix-its of group mates"? If not, I might have misunderstood the changes and will take a look again.


================
Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2394
+      for (const VarDecl *V : VarGroup) {
+        VarGrpMap[V] = GrpIdx;
       }
----------------
ziqingluo-90 wrote:
> Mapping variables to group indexes instead of groups themselves to avoid copies.
I think this is a really clever optimization and believe it would save a bunch of time and space in code having significant variable grouping. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156474



More information about the cfe-commits mailing list