diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll index d0935bb76d2e..32dec1355ea9 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll @@ -2275,6 +2275,12 @@ private predicate guardControlsPhiInput( */ signature predicate guardChecksSig(IRGuardCondition g, Expr e, boolean branch); +bindingset[g, n] +pragma[inline_late] +private predicate controls(IRGuardCondition g, Node n, boolean edge) { + g.controls(n.getBasicBlock(), edge) +} + /** * Provides a set of barrier nodes for a guard that validates an expression. * @@ -2318,15 +2324,17 @@ module BarrierGuard { exists(IRGuardCondition g, Expr e, ValueNumber value, boolean edge | e = value.getAnInstruction().getConvertedResultExpression() and result.asConvertedExpr() = e and - guardChecks(g, value.getAnInstruction().getConvertedResultExpression(), edge) and - g.controls(result.getBasicBlock(), edge) + guardChecks(g, + pragma[only_bind_into](value.getAnInstruction().getConvertedResultExpression()), edge) and + controls(g, result, edge) ) or exists( IRGuardCondition g, boolean branch, Ssa::DefinitionExt def, IRBlock input, Ssa::PhiNode phi | guardChecks(g, def.getARead().asOperand().getDef().getConvertedResultExpression(), branch) and - guardControlsPhiInput(g, branch, def, input, phi) and + guardControlsPhiInput(g, branch, def, pragma[only_bind_into](input), + pragma[only_bind_into](phi)) and result = TSsaPhiInputNode(phi, input) ) } @@ -2404,8 +2412,9 @@ module BarrierGuard { exists(IRGuardCondition g, Expr e, ValueNumber value, boolean edge | e = value.getAnInstruction().getConvertedResultExpression() and result.asIndirectConvertedExpr(indirectionIndex) = e and - guardChecks(g, value.getAnInstruction().getConvertedResultExpression(), edge) and - g.controls(result.getBasicBlock(), edge) + guardChecks(g, + pragma[only_bind_into](value.getAnInstruction().getConvertedResultExpression()), edge) and + controls(g, result, edge) ) or exists( @@ -2414,7 +2423,8 @@ module BarrierGuard { guardChecks(g, def.getARead().asIndirectOperand(indirectionIndex).getDef().getConvertedResultExpression(), branch) and - guardControlsPhiInput(g, branch, def, input, phi) and + guardControlsPhiInput(g, branch, def, pragma[only_bind_into](input), + pragma[only_bind_into](phi)) and result = TSsaPhiInputNode(phi, input) ) } @@ -2443,17 +2453,18 @@ module InstructionBarrierGuard