@@ -3,6 +3,7 @@ private import codeql.typetracking.TypeTracking as Tt
33private import codeql.util.Location
44private import codeql.util.Unit
55private import codeql.util.Option
6+ private import codeql.util.internal.MakeSets
67
78module MakeImplCommon< LocationSig Location, InputSig< Location > Lang> {
89 private import Lang
@@ -406,6 +407,27 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
406407 result = viableCallableLambda ( call , _)
407408 }
408409
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+
409431 signature module CallContextSensitivityInputSig {
410432 /** Holds if the edge is possibly needed in the direction `call` to `c`. */
411433 predicate relevantCallEdgeIn ( DataFlowCall call , DataFlowCallable c ) ;
@@ -1254,7 +1276,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
12541276 cached
12551277 newtype TLocalFlowCallContext =
12561278 TAnyLocalCall ( ) or
1257- TSpecificLocalCall ( DataFlowCall call ) { isUnreachableInCallCached ( _ , call ) }
1279+ TSpecificLocalCall ( UnreachableSets :: ValueSet ns )
12581280
12591281 cached
12601282 newtype TReturnKindExt =
@@ -1814,15 +1836,18 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
18141836 }
18151837
18161838 class LocalCallContextSpecificCall extends LocalCallContext , TSpecificLocalCall {
1817- LocalCallContextSpecificCall ( ) { this = TSpecificLocalCall ( call ) }
1839+ LocalCallContextSpecificCall ( ) { this = TSpecificLocalCall ( ns ) }
18181840
1819- DataFlowCall call ;
1841+ UnreachableSets :: ValueSet ns ;
18201842
1821- DataFlowCall getCall ( ) { result = call }
1843+ override string toString ( ) { result = "LocalCcCall" }
18221844
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+ }
18241848
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 ) ) }
18261851 }
18271852
18281853 private DataFlowCallable getNodeRegionEnclosingCallable ( NodeRegion nr ) {
@@ -1842,7 +1867,10 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
18421867 LocalCallContext getLocalCallContext ( CallContext ctx , DataFlowCallable callable ) {
18431868 ctx .relevantFor ( callable ) and
18441869 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 ) ) )
18461874 else result instanceof LocalCallContextAny
18471875 }
18481876
0 commit comments