Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions go/ql/lib/semmle/go/dataflow/internal/DataFlowUtil.qll
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ module BarrierGuard<guardChecksSig/3 guardChecks> {
localFlow(pragma[only_bind_out](outp.getNode(c)), resNode)
}

pragma[noinline]
private predicate guardsNode(Node g, Node arg, Node ret) {
exists(ControlFlow::ConditionGuardNode guard |
guards(g, guard, arg) and
guard.dominates(ret.getBasicBlock())
)
}

/**
* Holds if whenever `p` holds of output `outp` of function `f`, this node
* is known to validate the input `inp` of `f`.
Expand All @@ -357,10 +365,8 @@ module BarrierGuard<guardChecksSig/3 guardChecks> {
ret = outp.getEntryNode(fd) and
(
// Case: a function like "if someBarrierGuard(arg) { return true } else { return false }"
exists(ControlFlow::ConditionGuardNode guard |
guards(g, guard, arg) and
guard.dominates(ret.getBasicBlock())
|
guardsNode(g, arg, ret) and
(
exists(boolean b |
onlyPossibleReturnOfBool(fd, outp, ret, b) and
p.isBoolean(b)
Expand Down