Skip to content

Commit eea7804

Browse files
committed
C++: Join with value number only after joining with 'controls'.
1 parent 8efd870 commit eea7804

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,7 +2275,7 @@ private predicate guardControlsPhiInput(
22752275
*/
22762276
signature predicate guardChecksSig(IRGuardCondition g, Expr e, boolean branch);
22772277

2278-
bindingset[g, n]
2278+
bindingset[g]
22792279
pragma[inline_late]
22802280
private predicate controls(IRGuardCondition g, Node n, boolean edge) {
22812281
g.controls(n.getBasicBlock(), edge)
@@ -2288,6 +2288,13 @@ private predicate controls(IRGuardCondition g, Node n, boolean edge) {
22882288
* in data flow and taint tracking.
22892289
*/
22902290
module BarrierGuard<guardChecksSig/3 guardChecks> {
2291+
bindingset[value, n]
2292+
pragma[inline_late]
2293+
private predicate convertedExprHasValueNumber(Expr e, ValueNumber value, Node n) {
2294+
e = value.getAnInstruction().getConvertedResultExpression() and
2295+
n.asConvertedExpr() = e
2296+
}
2297+
22912298
/**
22922299
* Gets an expression node that is safely guarded by the given guard check.
22932300
*
@@ -2322,8 +2329,7 @@ module BarrierGuard<guardChecksSig/3 guardChecks> {
23222329
*/
23232330
Node getABarrierNode() {
23242331
exists(IRGuardCondition g, Expr e, ValueNumber value, boolean edge |
2325-
e = value.getAnInstruction().getConvertedResultExpression() and
2326-
result.asConvertedExpr() = e and
2332+
convertedExprHasValueNumber(e, value, result) and
23272333
guardChecks(g,
23282334
pragma[only_bind_into](value.getAnInstruction().getConvertedResultExpression()), edge) and
23292335
controls(g, result, edge)

0 commit comments

Comments
 (0)