@@ -545,6 +545,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
545545 private module Stage1 implements StageSig {
546546 class Ap = Unit ;
547547
548+ class ApNil = Ap ;
549+
548550 private class Cc = boolean ;
549551
550552 /* Begin: Stage 1 logic. */
@@ -1297,6 +1299,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
12971299 private signature module StageSig {
12981300 class Ap ;
12991301
1302+ class ApNil extends Ap ;
1303+
13001304 predicate revFlow ( NodeEx node ) ;
13011305
13021306 predicate revFlowAp ( NodeEx node , Ap ap ) ;
@@ -1723,6 +1727,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
17231727 DataFlowCall call , DataFlowCallable c , ParamNodeEx p , ApApprox apa , boolean emptyAp
17241728 ) ;
17251729
1730+ private signature predicate flowThroughSig ( ) ;
1731+
17261732 /**
17271733 * Exposes the inlined predicate `fwdFlowIn`, which is used to calculate both
17281734 * flow in and flow through.
@@ -1731,22 +1737,38 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
17311737 * need to record the argument that flows into the parameter.
17321738 *
17331739 * For flow through, we do need to record the argument, however, we can restrict
1734- * this to arguments that may actually flow through, using `callRestrictionSig `,
1740+ * this to arguments that may actually flow through, using `flowThroughSig `,
17351741 * which reduces the argument-to-parameter fan-in significantly.
17361742 */
1737- private module FwdFlowIn< callRestrictionSig / 5 callRestriction > {
1743+ private module FwdFlowIn< flowThroughSig / 0 flowThrough > {
17381744 pragma [ nomagic]
17391745 private predicate callEdgeArgParamRestricted (
17401746 DataFlowCall call , DataFlowCallable c , ArgNodeEx arg , ParamNodeEx p , boolean emptyAp ,
17411747 ApApprox apa
17421748 ) {
17431749 exists ( boolean allowsFieldFlow |
17441750 PrevStage:: callEdgeArgParam ( call , c , arg , p , allowsFieldFlow , apa ) and
1745- callRestriction ( call , c , p , apa , emptyAp )
1751+ if emptyAp = true then apa instanceof PrevStage :: ApNil else any ( )
17461752 |
1747- allowsFieldFlow = true
1748- or
1749- emptyAp = true
1753+ if
1754+ PrevStage:: callMayFlowThroughRev ( call ) and
1755+ PrevStage:: parameterMayFlowThrough ( p , apa )
1756+ then
1757+ emptyAp = true and
1758+ flowThrough ( )
1759+ or
1760+ emptyAp = false and
1761+ allowsFieldFlow = true and
1762+ if allowsFieldFlowThrough ( call , c ) then flowThrough ( ) else not flowThrough ( )
1763+ else (
1764+ not flowThrough ( ) and
1765+ (
1766+ emptyAp = true
1767+ or
1768+ emptyAp = false and
1769+ allowsFieldFlow = true
1770+ )
1771+ )
17501772 )
17511773 }
17521774
@@ -1876,21 +1898,9 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
18761898 }
18771899 }
18781900
1879- bindingset [ call, c, p, apa]
1880- private predicate callRestrictionNoFlowThrough (
1881- DataFlowCall call , DataFlowCallable c , ParamNodeEx p , ApApprox apa , boolean emptyAp
1882- ) {
1883- (
1884- if
1885- PrevStage:: callMayFlowThroughRev ( call ) and
1886- PrevStage:: parameterMayFlowThrough ( p , apa )
1887- then not allowsFieldFlowThrough ( call , c ) and emptyAp = false
1888- else emptyAp = [ false , true ]
1889- ) and
1890- exists ( c )
1891- }
1901+ private predicate bottom ( ) { none ( ) }
18921902
1893- private module FwdFlowInNoThrough = FwdFlowIn< callRestrictionNoFlowThrough / 5 > ;
1903+ private module FwdFlowInNoThrough = FwdFlowIn< bottom / 0 > ;
18941904
18951905 pragma [ nomagic]
18961906 private predicate fwdFlowInNoFlowThrough (
@@ -1899,21 +1909,9 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
18991909 FwdFlowInNoThrough:: fwdFlowIn ( _, _, _, p , state , _, innercc , _, t , ap , apa , _)
19001910 }
19011911
1902- bindingset [ call, c, p, apa]
1903- private predicate callRestrictionFlowThrough (
1904- DataFlowCall call , DataFlowCallable c , ParamNodeEx p , ApApprox apa , boolean emptyAp
1905- ) {
1906- PrevStage:: callMayFlowThroughRev ( call ) and
1907- PrevStage:: parameterMayFlowThrough ( p , apa ) and
1908- (
1909- emptyAp = true
1910- or
1911- allowsFieldFlowThrough ( call , c ) and
1912- emptyAp = false
1913- )
1914- }
1912+ private predicate top ( ) { any ( ) }
19151913
1916- private module FwdFlowInThrough = FwdFlowIn< callRestrictionFlowThrough / 5 > ;
1914+ private module FwdFlowInThrough = FwdFlowIn< top / 0 > ;
19171915
19181916 pragma [ nomagic]
19191917 private predicate fwdFlowInFlowThrough (
0 commit comments