@@ -1178,6 +1178,19 @@ module Make<LocationSig Location, InputSig<Location> Input> {
1178
1178
predicate hasCfgNode ( BasicBlock bb , int i ) ;
1179
1179
}
1180
1180
1181
+ /**
1182
+ * Gets a read of SSA defintion `def`.
1183
+ *
1184
+ * Override this with a cached version when applicable.
1185
+ */
1186
+ default Expr getARead ( Definition def ) {
1187
+ exists ( SourceVariable v , BasicBlock bb , int i |
1188
+ ssaDefReachesRead ( v , def , bb , i ) and
1189
+ variableRead ( bb , i , v , true ) and
1190
+ result .hasCfgNode ( bb , i )
1191
+ )
1192
+ }
1193
+
1181
1194
/** Holds if SSA definition `def` assigns `value` to the underlying variable. */
1182
1195
predicate ssaDefAssigns ( WriteDefinition def , Expr value ) ;
1183
1196
@@ -1224,15 +1237,6 @@ module Make<LocationSig Location, InputSig<Location> Input> {
1224
1237
module DataFlowIntegration< DataFlowIntegrationInputSig DfInput> {
1225
1238
private import codeql.util.Boolean
1226
1239
1227
- pragma [ nomagic]
1228
- private DfInput:: Expr getARead ( Definition def ) {
1229
- exists ( SourceVariable v , BasicBlock bb , int i |
1230
- ssaDefReachesRead ( v , def , bb , i ) and
1231
- variableRead ( bb , i , v , true ) and
1232
- result .hasCfgNode ( bb , i )
1233
- )
1234
- }
1235
-
1236
1240
pragma [ nomagic]
1237
1241
private predicate adjacentDefReachesReadExt (
1238
1242
DefinitionExt def , SourceVariable v , BasicBlock bb1 , int i1 , BasicBlock bb2 , int i2
@@ -1322,7 +1326,7 @@ module Make<LocationSig Location, InputSig<Location> Input> {
1322
1326
private newtype TNode =
1323
1327
TParamNode ( DfInput:: Parameter p ) { DfInput:: ssaDefInitializesParam ( _, p ) } or
1324
1328
TExprNode ( DfInput:: Expr e , Boolean isPost ) {
1325
- e = getARead ( _)
1329
+ e = DfInput :: getARead ( _)
1326
1330
or
1327
1331
DfInput:: ssaDefAssigns ( _, e ) and
1328
1332
isPost = false
@@ -1545,7 +1549,12 @@ module Make<LocationSig Location, InputSig<Location> Input> {
1545
1549
)
1546
1550
}
1547
1551
1548
- /** Holds if there is a local flow step from `nodeFrom` to `nodeTo`. */
1552
+ /**
1553
+ * Holds if there is a local flow step from `nodeFrom` to `nodeTo`.
1554
+ *
1555
+ * `isUseStep` is `true` when `nodeFrom` is a (post-update) read node and
1556
+ * `nodeTo` is a read node or phi (read) node.
1557
+ */
1549
1558
predicate localFlowStep ( DefinitionExt def , Node nodeFrom , Node nodeTo , boolean isUseStep ) {
1550
1559
(
1551
1560
// Flow from assignment into SSA definition
@@ -1594,7 +1603,7 @@ module Make<LocationSig Location, InputSig<Location> Input> {
1594
1603
or
1595
1604
// Flow from SSA definition to read
1596
1605
nodeFrom .( SsaDefinitionExtNode ) .getDefinitionExt ( ) = def and
1597
- nodeTo .( ExprNode ) .getExpr ( ) = getARead ( def )
1606
+ nodeTo .( ExprNode ) .getExpr ( ) = DfInput :: getARead ( def )
1598
1607
}
1599
1608
1600
1609
pragma [ nomagic]
@@ -1603,7 +1612,7 @@ module Make<LocationSig Location, InputSig<Location> Input> {
1603
1612
) {
1604
1613
exists ( BasicBlock bb , DfInput:: Expr e |
1605
1614
e = n .getExpr ( ) and
1606
- getARead ( def ) = e and
1615
+ DfInput :: getARead ( def ) = e and
1607
1616
DfInput:: guardControlsBlock ( g , bb , branch ) and
1608
1617
e .hasCfgNode ( bb , _)
1609
1618
)
0 commit comments