[PATCH] D138253: [-Wunsafe-buffer-usage] NFC: Implement fix-strategies and variable-use-claiming.
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 17 19:19:16 PST 2022
NoQ added inline comments.
================
Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:236
+ using UseSetTy = SmallSet<const DeclRefExpr *, 16>;
+ using DefMapTy = DenseMap<const VarDecl *, const DeclStmt *>;
+
----------------
This extra payload wasn't advertised but it's very useful because it's hard to jump from `VarDecl` to `DeclStmt` without it, and we need to do such jump because our analysis starts from unsafe *uses* of a variable, which only give us a `VarDecl`.
================
Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:447-451
+ // FIXME: This isn't sufficient (or even correct) when a gadget has
+ // already produced a fixit for a different variable i.e. it was mentioned
+ // in the map twice (or more). In such case the correct thing to do is
+ // to undo the previous fix first, and then if we can't produce the new
+ // fix for both variables, revert to the old one.
----------------
We're safe for now because none of the currently implemented `Gadget` classes "claim" more than one `DeclRefExpr`. We need to address this FIXME before we implement such gadgets.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138253/new/
https://reviews.llvm.org/D138253
More information about the cfe-commits
mailing list