Details
- Reviewers
jkorous NoQ ziqingluo-90 malavikasamak
Diff Detail
Event Timeline
Ooo, that's a big one. Our first fixable that can connect multiple variables together. IIUC this patch doesn't yet teach the strategy machine how to pick related strategies for related variables, it just teaches the fixit machine what to do when the strategy is already picked.
clang/lib/Analysis/UnsafeBufferUsage.cpp | ||
---|---|---|
463–465 | Shouldn't it also claim the RHS? Otherwise, how would the machine know that it's covered? | |
761 | I suspect you want to check the strategy for LHS here as well. Just because the method was called, doesn't mean we plan to use span over it specifically. | |
1046 | Oh, that's probably why it worked without the other claim! |
Wait, I completely misread, you *were* trying to mutate the strategy. I think it makes sense to split this work the way I thought it's already split: first get fixits when the strategy is already set (which this patch almost has), then try to figure out how to mutate and fixpoint-iterate-over the strategy.
WIP: Fixable for ptr1 = ptr2 when both LHS and RHS have their fixit strategies set as std::span.
- Fixes crash caused by FixableGadgetSets and WarningGadgetSets being unique pointers in the context of multiple declaration gadgets.
Aha, great! Looks like our fancy ownership model couldn't handle shared ownership for multi-variable gadgets, so we're back to raw pointers. Works for me, it's not like they're buffers or something. I have minor nitpicks and then I think we can land!
clang/lib/Analysis/UnsafeBufferUsage.cpp | ||
---|---|---|
452–453 | I think this overruns the 80-column limit. | |
463–464 | I think these checks should be included in the matcher(). There could be a different Fixable that takes care of these non-variable cases, and if there indeed is one, we really don't want to it to overlap with this Fixable. | |
691 | clang-format will probably recommend a space there. | |
1041 | Now that they're in the same scope, the move doesn't really accomplish anything. You can probably drop the Tracker variable and rename TrackerRes to Tracker. |
clang/lib/Analysis/UnsafeBufferUsage.cpp | ||
---|---|---|
467 | Since the matcher only requires PtrLHS (or PtrRHS) to be Expr instead of specifically DeclRefExpr, we could have LDRE (or RDRE respectively) be null here. |
clang/lib/Analysis/UnsafeBufferUsage.cpp | ||
---|---|---|
467 | I am wondering if we should simply move the logic related to DeclRefExpr and IgnoreParenImpCasts to the matcher() method (expressed as AST matcher). |
We've noticed a subtle problem offline yesterday: sounds like if fixits for both sides are desired (like in the primary test case) but one of them can't be emitted (eg., due to unsupported variable use) then the other fixit alone will be incorrect: it'll act as if both p and q are spanified, so it'll emit no change for p = q. Also generally, we really don't want users to apply fixits for p and q independently; that won't lead to correct code. So it sounds like we cannot land this patch until we learn how to group related variables together.
Nit: assignment seems to have only one form :)