[PATCH] D143128: [-Wunsafe-buffer-usage] Fix-Its transforming `&DRE[any]` to `(DRE.data() + any)`

Rashmi Mudduluru via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 6 10:51:13 PST 2023


t-rasmud added inline comments.


================
Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:1079
+            dyn_cast<DeclRefExpr>(ArraySub->getBase()->IgnoreImpCasts())) {
+      // FIXME: this `getASTContext` call is costy, we should pass the
+      // ASTContext in:
----------------
Nit: "costly"


================
Comment at: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp:74
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]
+}
----------------
Can we have a test case for `&p[0]`? 
IIUC, this would generate a fixit `p.data() + 0` which is correct but we might want to optimize it to `p.data()` sometime in the future.


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

https://reviews.llvm.org/D143128



More information about the cfe-commits mailing list