@@ -3,6 +3,7 @@ private import codeql.typetracking.TypeTracking as Tt
3
3
private import codeql.util.Location
4
4
private import codeql.util.Unit
5
5
private import codeql.util.Option
6
+ private import codeql.util.internal.MakeSets
6
7
7
8
module MakeImplCommon< LocationSig Location, InputSig< Location > Lang> {
8
9
private import Lang
@@ -406,6 +407,27 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
406
407
result = viableCallableLambda ( call , _)
407
408
}
408
409
410
+ private newtype TCallEdge =
411
+ TMkCallEdge ( DataFlowCall call , DataFlowCallable tgt ) { viableCallableExt ( call ) = tgt }
412
+
413
+ private module UnreachableSetsInput implements MkSetsInp {
414
+ class Key = TCallEdge ;
415
+
416
+ class Value = NodeRegion ;
417
+
418
+ NodeRegion getAValue ( TCallEdge edge ) {
419
+ exists ( DataFlowCall call , DataFlowCallable tgt |
420
+ edge = TMkCallEdge ( call , tgt ) and
421
+ getNodeRegionEnclosingCallable ( result ) = tgt and
422
+ isUnreachableInCallCached ( result , call )
423
+ )
424
+ }
425
+
426
+ int totalorder ( NodeRegion nr ) { result = nr .totalOrder ( ) }
427
+ }
428
+
429
+ private module UnreachableSets = MakeSets< UnreachableSetsInput > ;
430
+
409
431
signature module CallContextSensitivityInputSig {
410
432
/** Holds if the edge is possibly needed in the direction `call` to `c`. */
411
433
predicate relevantCallEdgeIn ( DataFlowCall call , DataFlowCallable c ) ;
@@ -1254,7 +1276,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
1254
1276
cached
1255
1277
newtype TLocalFlowCallContext =
1256
1278
TAnyLocalCall ( ) or
1257
- TSpecificLocalCall ( DataFlowCall call ) { isUnreachableInCallCached ( _ , call ) }
1279
+ TSpecificLocalCall ( UnreachableSets :: ValueSet ns )
1258
1280
1259
1281
cached
1260
1282
newtype TReturnKindExt =
@@ -1814,15 +1836,18 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
1814
1836
}
1815
1837
1816
1838
class LocalCallContextSpecificCall extends LocalCallContext , TSpecificLocalCall {
1817
- LocalCallContextSpecificCall ( ) { this = TSpecificLocalCall ( call ) }
1839
+ LocalCallContextSpecificCall ( ) { this = TSpecificLocalCall ( ns ) }
1818
1840
1819
- DataFlowCall call ;
1841
+ UnreachableSets :: ValueSet ns ;
1820
1842
1821
- DataFlowCall getCall ( ) { result = call }
1843
+ override string toString ( ) { result = "LocalCcCall" }
1822
1844
1823
- override string toString ( ) { result = "LocalCcCall(" + call + ")" }
1845
+ override predicate relevantFor ( DataFlowCallable callable ) {
1846
+ exists ( NodeRegion nr | ns .contains ( nr ) and callable = getNodeRegionEnclosingCallable ( nr ) )
1847
+ }
1824
1848
1825
- override predicate relevantFor ( DataFlowCallable callable ) { relevantLocalCCtx ( call , callable ) }
1849
+ /** Holds if this call context makes `n` unreachable. */
1850
+ predicate unreachable ( Node n ) { exists ( NodeRegion nr | ns .contains ( nr ) and nr .contains ( n ) ) }
1826
1851
}
1827
1852
1828
1853
private DataFlowCallable getNodeRegionEnclosingCallable ( NodeRegion nr ) {
@@ -1842,7 +1867,10 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
1842
1867
LocalCallContext getLocalCallContext ( CallContext ctx , DataFlowCallable callable ) {
1843
1868
ctx .relevantFor ( callable ) and
1844
1869
if relevantLocalCCtx ( ctx .( CallContextSpecificCall ) .getCall ( ) , callable )
1845
- then result .( LocalCallContextSpecificCall ) .getCall ( ) = ctx .( CallContextSpecificCall ) .getCall ( )
1870
+ then
1871
+ result =
1872
+ TSpecificLocalCall ( UnreachableSets:: getValueSet ( TMkCallEdge ( ctx .( CallContextSpecificCall )
1873
+ .getCall ( ) , callable ) ) )
1846
1874
else result instanceof LocalCallContextAny
1847
1875
}
1848
1876
0 commit comments