Data flow: Sync files

This commit is contained in:
Tom Hvitved
2022-10-05 11:27:39 +02:00
parent 3f0f16afc4
commit 6f518c1996
4 changed files with 92 additions and 24 deletions

View File

@@ -750,6 +750,27 @@ module Private {
)
}
/**
* Holds if `p` can reach `n` in a summarized callable, using only value-preserving
* local steps. `clearsOrExcepts` records whether any node on the path from `p` to
* `n` either clears or expects contents.
*/
private predicate paramReachesLocal(ParamNode p, Node n, boolean clearsOrExcepts) {
viableParam(_, _, _, p) and
n = p and
clearsOrExcepts = false
or
exists(Node mid, boolean clearsOrExceptsMid |
paramReachesLocal(p, mid, clearsOrExceptsMid) and
summaryLocalStep(mid, n, true) and
if
summaryClearsContent(n, _) or
summaryExpectsContent(n, _)
then clearsOrExcepts = true
else clearsOrExcepts = clearsOrExceptsMid
)
}
/**
* Holds if use-use flow starting from `arg` should be prohibited.
*
@@ -759,15 +780,11 @@ module Private {
*/
pragma[nomagic]
predicate prohibitsUseUseFlow(ArgNode arg, SummarizedCallable sc) {
exists(ParamNode p, Node mid, ParameterPosition ppos, Node ret |
exists(ParamNode p, ParameterPosition ppos, Node ret |
paramReachesLocal(p, ret, true) and
p = summaryArgParam0(_, arg, sc) and
p.isParameterOf(_, pragma[only_bind_into](ppos)) and
summaryLocalStep(p, mid, true) and
summaryLocalStep(mid, ret, true) and
isParameterPostUpdate(ret, _, pragma[only_bind_into](ppos))
|
summaryClearsContent(mid, _) or
summaryExpectsContent(mid, _)
)
}