Skip to content

Commit 32e5525

Browse files
committed
ssa: Update some uses of ExprNode to bind the variable
1 parent cbd6d35 commit 32e5525

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎shared/ssa/codeql/ssa/Ssa.qll‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,9 @@ module Make<
17421742
/** Gets the underlying expression. */
17431743
DfInput::Expr getExpr() { result = e }
17441744

1745+
/** Holds if represents the access to `var` performed at `expr`. */
1746+
predicate isExprAndVariable(DfInput::Expr expr, SourceVariable var) { expr = e and var = v_ }
1747+
17451748
override Location getLocation() {
17461749
exists(BasicBlock bb, int i |
17471750
e.hasCfgNode(bb, i) and
@@ -1769,7 +1772,7 @@ module Make<
17691772
ExprPostUpdateNodeImpl() { isPost = true }
17701773

17711774
/** Gets the pre-update expression node. */
1772-
ExprNode getPreUpdateNode() { result = TExprNode(e, _, false) }
1775+
ExprNode getPreUpdateNode() { result = TExprNode(e, v_, false) }
17731776

17741777
override string toString() { result = e.toString() + " [postupdate]" }
17751778
}
@@ -2026,13 +2029,13 @@ module Make<
20262029
v = def.getSourceVariable() and
20272030
if DfInput::includeWriteDefsInFlowStep()
20282031
then nodeTo.(SsaDefinitionNode).getDefinition() = def
2029-
else nodeTo.(ExprNode).getExpr() = DfInput::getARead(def)
2032+
else nodeTo.(ExprNode).isExprAndVariable(DfInput::getARead(def), v)
20302033
)
20312034
or
20322035
// Flow from SSA definition to read
20332036
exists(DefinitionExt def |
20342037
nodeFrom.(SsaDefinitionExtNodeImpl).getDefExt() = def and
2035-
nodeTo.(ExprNode).getExpr() = DfInput::getARead(def) and
2038+
nodeTo.(ExprNode).isExprAndVariable(DfInput::getARead(def), v) and
20362039
v = def.getSourceVariable()
20372040
)
20382041
}
@@ -2138,7 +2141,7 @@ module Make<
21382141
e = DfInput::getARead(def) and
21392142
e.hasCfgNode(bb, _) and
21402143
DfInput::guardControlsBlock(g, bb, val) and
2141-
result.(ExprNode).getExpr() = e
2144+
result.(ExprNode).isExprAndVariable(e, def.getSourceVariable())
21422145
)
21432146
or
21442147
// guard controls input block to a phi node

0 commit comments

Comments
 (0)