@@ -1307,33 +1307,39 @@ private predicate localFlowExit(Node node, Configuration config) {
1307
1307
*/
1308
1308
pragma [ nomagic]
1309
1309
private predicate localFlowStepPlus (
1310
- Node node1 , Node node2 , boolean preservesValue , Configuration config , LocalCallContext cc
1310
+ Node node1 , Node node2 , boolean preservesValue , DataFlowType t , Configuration config ,
1311
+ LocalCallContext cc
1311
1312
) {
1312
1313
not isUnreachableInCall ( node2 , cc .( LocalCallContextSpecificCall ) .getCall ( ) ) and
1313
1314
(
1314
1315
localFlowEntry ( node1 , config ) and
1315
1316
(
1316
- localFlowStep ( node1 , node2 , config ) and preservesValue = true
1317
+ localFlowStep ( node1 , node2 , config ) and
1318
+ preservesValue = true and
1319
+ t = getErasedNodeTypeBound ( node1 )
1317
1320
or
1318
- additionalLocalFlowStep ( node1 , node2 , config ) and preservesValue = false
1321
+ additionalLocalFlowStep ( node1 , node2 , config ) and
1322
+ preservesValue = false and
1323
+ t = getErasedNodeTypeBound ( node2 )
1319
1324
) and
1320
1325
node1 != node2 and
1321
1326
cc .relevantFor ( node1 .getEnclosingCallable ( ) ) and
1322
1327
not isUnreachableInCall ( node1 , cc .( LocalCallContextSpecificCall ) .getCall ( ) ) and
1323
1328
nodeCand ( TNormalNode ( node2 ) , unbind ( config ) )
1324
1329
or
1325
1330
exists ( Node mid |
1326
- localFlowStepPlus ( node1 , mid , preservesValue , config , cc ) and
1331
+ localFlowStepPlus ( node1 , mid , preservesValue , t , config , cc ) and
1327
1332
localFlowStep ( mid , node2 , config ) and
1328
1333
not mid instanceof CastNode and
1329
1334
nodeCand ( TNormalNode ( node2 ) , unbind ( config ) )
1330
1335
)
1331
1336
or
1332
1337
exists ( Node mid |
1333
- localFlowStepPlus ( node1 , mid , _, config , cc ) and
1338
+ localFlowStepPlus ( node1 , mid , _, _ , config , cc ) and
1334
1339
additionalLocalFlowStep ( mid , node2 , config ) and
1335
1340
not mid instanceof CastNode and
1336
1341
preservesValue = false and
1342
+ t = getErasedNodeTypeBound ( node2 ) and
1337
1343
nodeCand ( TNormalNode ( node2 ) , unbind ( config ) )
1338
1344
)
1339
1345
)
@@ -1345,17 +1351,18 @@ private predicate localFlowStepPlus(
1345
1351
*/
1346
1352
pragma [ nomagic]
1347
1353
private predicate localFlowBigStep (
1348
- Node node1 , Node node2 , boolean preservesValue , Configuration config , LocalCallContext callContext
1354
+ Node node1 , Node node2 , boolean preservesValue , DataFlowType t , Configuration config ,
1355
+ LocalCallContext callContext
1349
1356
) {
1350
- localFlowStepPlus ( node1 , node2 , preservesValue , config , callContext ) and
1357
+ localFlowStepPlus ( node1 , node2 , preservesValue , t , config , callContext ) and
1351
1358
localFlowExit ( node2 , config )
1352
1359
}
1353
1360
1354
1361
pragma [ nomagic]
1355
1362
private predicate localFlowBigStepExt (
1356
- NodeExt node1 , NodeExt node2 , boolean preservesValue , Configuration config
1363
+ NodeExt node1 , NodeExt node2 , boolean preservesValue , AccessPathFrontNil apf , Configuration config
1357
1364
) {
1358
- localFlowBigStep ( node1 .getNode ( ) , node2 .getNode ( ) , preservesValue , config , _)
1365
+ localFlowBigStep ( node1 .getNode ( ) , node2 .getNode ( ) , preservesValue , apf . getType ( ) , config , _)
1359
1366
}
1360
1367
1361
1368
private newtype TAccessPathFront =
@@ -1395,46 +1402,24 @@ private predicate flowCandFwd(
1395
1402
else any ( )
1396
1403
}
1397
1404
1398
- /**
1399
- * A node that requires an empty access path and should have its tracked type
1400
- * (re-)computed. This is either a source or a node reached through an
1401
- * additional step.
1402
- */
1403
- private class AccessPathFrontNilNode extends NormalNodeExt {
1404
- AccessPathFrontNilNode ( ) {
1405
- nodeCand ( this , _) and
1406
- (
1407
- any ( Configuration c ) .isSource ( this .getNode ( ) )
1408
- or
1409
- localFlowBigStepExt ( _, this , false , _)
1410
- or
1411
- additionalJumpStepExt ( _, this , _)
1412
- )
1413
- }
1414
-
1415
- /** Gets the `nil` path front for this node. */
1416
- AccessPathFrontNil getApf ( ) { result = TFrontNil ( this .getErasedNodeTypeBound ( ) ) }
1417
- }
1418
-
1419
1405
private predicate flowCandFwd0 (
1420
1406
NodeExt node , boolean fromArg , AccessPathFront apf , Configuration config
1421
1407
) {
1422
1408
nodeCand2 ( node , _, false , config ) and
1423
1409
config .isSource ( node .getNode ( ) ) and
1424
1410
fromArg = false and
1425
- apf = node .( AccessPathFrontNilNode ) . getApf ( )
1411
+ apf = TFrontNil ( node .getErasedNodeTypeBound ( ) )
1426
1412
or
1427
1413
nodeCand ( node , unbind ( config ) ) and
1428
1414
(
1429
1415
exists ( NodeExt mid |
1430
1416
flowCandFwd ( mid , fromArg , apf , config ) and
1431
- localFlowBigStepExt ( mid , node , true , config )
1417
+ localFlowBigStepExt ( mid , node , true , _ , config )
1432
1418
)
1433
1419
or
1434
1420
exists ( NodeExt mid , AccessPathFrontNil nil |
1435
1421
flowCandFwd ( mid , fromArg , nil , config ) and
1436
- localFlowBigStepExt ( mid , node , false , config ) and
1437
- apf = node .( AccessPathFrontNilNode ) .getApf ( )
1422
+ localFlowBigStepExt ( mid , node , false , apf , config )
1438
1423
)
1439
1424
or
1440
1425
exists ( NodeExt mid |
@@ -1447,7 +1432,7 @@ private predicate flowCandFwd0(
1447
1432
flowCandFwd ( mid , _, nil , config ) and
1448
1433
additionalJumpStepExt ( mid , node , config ) and
1449
1434
fromArg = false and
1450
- apf = node .( AccessPathFrontNilNode ) . getApf ( )
1435
+ apf = TFrontNil ( node .getErasedNodeTypeBound ( ) )
1451
1436
)
1452
1437
or
1453
1438
exists ( NodeExt mid , boolean allowsFieldFlow |
@@ -1589,13 +1574,13 @@ private predicate flowCand0(
1589
1574
apf instanceof AccessPathFrontNil
1590
1575
or
1591
1576
exists ( NodeExt mid |
1592
- localFlowBigStepExt ( node , mid , true , config ) and
1577
+ localFlowBigStepExt ( node , mid , true , _ , config ) and
1593
1578
flowCand ( mid , toReturn , apf , config )
1594
1579
)
1595
1580
or
1596
1581
exists ( NodeExt mid , AccessPathFrontNil nil |
1597
1582
flowCandFwd ( node , _, apf , config ) and
1598
- localFlowBigStepExt ( node , mid , false , config ) and
1583
+ localFlowBigStepExt ( node , mid , false , _ , config ) and
1599
1584
flowCand ( mid , toReturn , nil , config ) and
1600
1585
apf instanceof AccessPathFrontNil
1601
1586
)
@@ -1810,18 +1795,6 @@ private predicate popWithFront(AccessPath ap0, Content f, AccessPathFront apf, A
1810
1795
/** Gets the access path obtained by pushing `f` onto `ap`. */
1811
1796
private AccessPath push ( Content f , AccessPath ap ) { ap = pop ( f , result ) }
1812
1797
1813
- /**
1814
- * A node that requires an empty access path and should have its tracked type
1815
- * (re-)computed. This is either a source or a node reached through an
1816
- * additional step.
1817
- */
1818
- private class AccessPathNilNode extends NormalNodeExt {
1819
- AccessPathNilNode ( ) { flowCand ( this .( AccessPathFrontNilNode ) , _, _, _) }
1820
-
1821
- /** Gets the `nil` path for this node. */
1822
- AccessPathNil getAp ( ) { result = TNil ( this .getErasedNodeTypeBound ( ) ) }
1823
- }
1824
-
1825
1798
/**
1826
1799
* Holds if data can flow from a source to `node` with the given `ap`.
1827
1800
*/
@@ -1838,20 +1811,19 @@ private predicate flowFwd0(
1838
1811
flowCand ( node , _, _, config ) and
1839
1812
config .isSource ( node .getNode ( ) ) and
1840
1813
fromArg = false and
1841
- ap = node .( AccessPathNilNode ) . getAp ( ) and
1814
+ ap = TNil ( node .getErasedNodeTypeBound ( ) ) and
1842
1815
apf = ap .( AccessPathNil ) .getFront ( )
1843
1816
or
1844
1817
flowCand ( node , _, _, unbind ( config ) ) and
1845
1818
(
1846
1819
exists ( NodeExt mid |
1847
1820
flowFwd ( mid , fromArg , apf , ap , config ) and
1848
- localFlowBigStepExt ( mid , node , true , config )
1821
+ localFlowBigStepExt ( mid , node , true , _ , config )
1849
1822
)
1850
1823
or
1851
1824
exists ( NodeExt mid , AccessPathNil nil |
1852
1825
flowFwd ( mid , fromArg , _, nil , config ) and
1853
- localFlowBigStepExt ( mid , node , false , config ) and
1854
- ap = node .( AccessPathNilNode ) .getAp ( ) and
1826
+ localFlowBigStepExt ( mid , node , false , apf , config ) and
1855
1827
apf = ap .( AccessPathNil ) .getFront ( )
1856
1828
)
1857
1829
or
@@ -1865,7 +1837,7 @@ private predicate flowFwd0(
1865
1837
flowFwd ( mid , _, _, nil , config ) and
1866
1838
additionalJumpStepExt ( mid , node , config ) and
1867
1839
fromArg = false and
1868
- ap = node .( AccessPathNilNode ) . getAp ( ) and
1840
+ ap = TNil ( node .getErasedNodeTypeBound ( ) ) and
1869
1841
apf = ap .( AccessPathNil ) .getFront ( )
1870
1842
)
1871
1843
or
@@ -1982,13 +1954,13 @@ private predicate flow0(NodeExt node, boolean toReturn, AccessPath ap, Configura
1982
1954
ap instanceof AccessPathNil
1983
1955
or
1984
1956
exists ( NodeExt mid |
1985
- localFlowBigStepExt ( node , mid , true , config ) and
1957
+ localFlowBigStepExt ( node , mid , true , _ , config ) and
1986
1958
flow ( mid , toReturn , ap , config )
1987
1959
)
1988
1960
or
1989
1961
exists ( NodeExt mid , AccessPathNil nil |
1990
1962
flowFwd ( node , _, _, ap , config ) and
1991
- localFlowBigStepExt ( node , mid , false , config ) and
1963
+ localFlowBigStepExt ( node , mid , false , _ , config ) and
1992
1964
flow ( mid , toReturn , nil , config ) and
1993
1965
ap instanceof AccessPathNil
1994
1966
)
@@ -2164,7 +2136,7 @@ private newtype TPathNode =
2164
2136
config .isSource ( node ) and
2165
2137
cc instanceof CallContextAny and
2166
2138
sc instanceof SummaryCtxNone and
2167
- ap = any ( AccessPathNilNode nil | nil . getNode ( ) = node ) . getAp ( )
2139
+ ap = TNil ( getErasedNodeTypeBound ( node ) )
2168
2140
or
2169
2141
// ... or a step from an existing PathNode to another node.
2170
2142
exists ( PathNodeMid mid |
@@ -2357,12 +2329,11 @@ private predicate pathStep(PathNodeMid mid, Node node, CallContext cc, SummaryCt
2357
2329
pathIntoLocalStep ( mid , midnode , cc , enclosing , sc , ap0 , conf ) and
2358
2330
localCC = getLocalCallContext ( cc , enclosing )
2359
2331
|
2360
- localFlowBigStep ( midnode , node , true , conf , localCC ) and
2332
+ localFlowBigStep ( midnode , node , true , _ , conf , localCC ) and
2361
2333
ap = ap0
2362
2334
or
2363
- localFlowBigStep ( midnode , node , false , conf , localCC ) and
2364
- ap0 instanceof AccessPathNil and
2365
- ap = any ( AccessPathNilNode nil | nil .getNode ( ) = node ) .getAp ( )
2335
+ localFlowBigStep ( midnode , node , false , ap .( AccessPathNil ) .getType ( ) , conf , localCC ) and
2336
+ ap0 instanceof AccessPathNil
2366
2337
)
2367
2338
or
2368
2339
jumpStep ( mid .getNode ( ) , node , mid .getConfiguration ( ) ) and
@@ -2374,7 +2345,7 @@ private predicate pathStep(PathNodeMid mid, Node node, CallContext cc, SummaryCt
2374
2345
cc instanceof CallContextAny and
2375
2346
sc instanceof SummaryCtxNone and
2376
2347
mid .getAp ( ) instanceof AccessPathNil and
2377
- ap = any ( AccessPathNilNode nil | nil . getNode ( ) = node ) . getAp ( )
2348
+ ap = TNil ( getErasedNodeTypeBound ( node ) )
2378
2349
or
2379
2350
exists ( Content f , AccessPath ap0 | pathReadStep ( mid , node , ap0 , f , cc ) and ap = pop ( f , ap0 ) ) and
2380
2351
sc = mid .getSummaryCtx ( )
@@ -2397,7 +2368,7 @@ private predicate pathIntoLocalStep(
2397
2368
midnode = mid .getNode ( ) and
2398
2369
cc = mid .getCallContext ( ) and
2399
2370
conf = mid .getConfiguration ( ) and
2400
- localFlowBigStep ( midnode , _, _, conf , _) and
2371
+ localFlowBigStep ( midnode , _, _, _ , conf , _) and
2401
2372
enclosing = midnode .getEnclosingCallable ( ) and
2402
2373
sc = mid .getSummaryCtx ( ) and
2403
2374
ap0 = mid .getAp ( )
0 commit comments