Skip to content

Commit 75e57dd

Browse files
committed
ssa: Associate ExprNode with a variable
1 parent 9d8f5e6 commit 75e57dd

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,12 @@ module Make<
16801680
cached
16811681
private newtype TNode =
16821682
TWriteDefSource(WriteDefinition def) { DfInput::ssaDefHasSource(def) } or
1683-
TExprNode(DfInput::Expr e, Boolean isPost) { e = DfInput::getARead(_) } or
1683+
TExprNode(DfInput::Expr e, SourceVariable v, Boolean isPost) {
1684+
exists(Definition def |
1685+
def.getSourceVariable() = v and
1686+
e = DfInput::getARead(def)
1687+
)
1688+
} or
16841689
TSsaDefinitionNode(DefinitionExt def) {
16851690
not phiHasUniqNextNode(def) and
16861691
if DfInput::includeWriteDefsInFlowStep()
@@ -1730,8 +1735,9 @@ module Make<
17301735
abstract private class ExprNodePreOrPostImpl extends NodeImpl, TExprNode {
17311736
DfInput::Expr e;
17321737
boolean isPost;
1738+
SourceVariable v_;
17331739

1734-
ExprNodePreOrPostImpl() { this = TExprNode(e, isPost) }
1740+
ExprNodePreOrPostImpl() { this = TExprNode(e, v_, isPost) }
17351741

17361742
/** Gets the underlying expression. */
17371743
DfInput::Expr getExpr() { result = e }
@@ -1742,6 +1748,9 @@ module Make<
17421748
result = bb.getNode(i).getLocation()
17431749
)
17441750
}
1751+
1752+
/** Gets the variable accessed at this expression. */
1753+
SourceVariable getSourceVariable() { result = v_ }
17451754
}
17461755

17471756
final class ExprNodePreOrPost = ExprNodePreOrPostImpl;
@@ -1760,7 +1769,7 @@ module Make<
17601769
ExprPostUpdateNodeImpl() { isPost = true }
17611770

17621771
/** Gets the pre-update expression node. */
1763-
ExprNode getPreUpdateNode() { result = TExprNode(e, false) }
1772+
ExprNode getPreUpdateNode() { result = TExprNode(e, _, false) }
17641773

17651774
override string toString() { result = e.toString() + " [postupdate]" }
17661775
}
@@ -1770,7 +1779,6 @@ module Make<
17701779
private class ReadNodeImpl extends ExprNodeImpl {
17711780
private BasicBlock bb_;
17721781
private int i_;
1773-
private SourceVariable v_;
17741782

17751783
ReadNodeImpl() {
17761784
variableRead(bb_, i_, v_, true) and

0 commit comments

Comments
 (0)