C++: Barrier guards API for indirect expressions#12970
C++: Barrier guards API for indirect expressions#12970MathiasVP merged 6 commits intogithub:mainfrom
Conversation
…really what we expect people to write in queries.
|
Why not just change |
That would also be fine, but then users would have to add an additional check in their I could imagine both situations, really. Most of the time users probably don't care which one they sanitize because they just want to remove some FP they're seeing. But I personally like to be able to distinguish the two cases, and still keep the pretty one-liner that you get from writing barrier = DataFlow::BarrierGuard<testBarrierGuard/3>::getAnIndirectBarrierNode()(😍) |
Right, if you imagine use-cases where you'll want to only have one or the other then it makes sense, but I just thought that you'd always want both. |
|
If indeed there are such use-cases that merit a split like this, then the qldoc probably needs some elaboration, because it's not at all clear that such use-cases exist, so that'll probably make it hard for users to figure out when to use one or the other or both. |
Good point. I'll add some QLDoc. The concept of "indirect expression" is explained in some other QLDoc, but it can't hurt to add a more specific explanation within the context of barrier guards 👍. |
👍 Nicely elaborate. |
jketema
left a comment
There was a problem hiding this comment.
LGTM, one small comment. I assume we can skip any DCA experiment, because the new predicate is not used in any query?
| } | ||
|
|
||
| /** Gets an indirect expression node that is safely guarded by the given guard check. */ | ||
| IndirectExprNode getAnIndirectBarrierNode() { |
There was a problem hiding this comment.
Do we want to expose the indirection index here as an argument of getAnIndirectBarrierNode?
There was a problem hiding this comment.
We could do that, yeah. And then implement a getAnIndirectBarrierNode with no parameters as getAnIndirectBarrierNode(_)?
Yeah, I don't see any reason to run DCA here 👍. |
Background
In the rewrite to use-use flow for C/C++ we added a concept of an indirect node which represents "the value you'd get by dereferencing the value of the expression represented by this node". These are the nodes accessible using the
Node::asIndirectExpr()predicate which returns anIndirectExprNode(instead of anExprNode).The problem
These new
IndirectExprNodes couldn't be marked as barriers with a barrier guard because the predicate offered by theBarrierGuardparameterized module had the signature:which meant that an
IndirectExprNodes was never the result of this predicate.This PR
To resolve the above issue, I've added a new predicate to the
BarrierGuardparameterized module with the signature:the implementation is syntactically identical: the only change is the return type.
Commit-by-commit review recommended.
BarrierGuardAPI (instead of theInstruction-based one). I don't think we want users to use theInstruction-based one anyway, and we should test the APIs we tell people to use.