@@ -545,6 +545,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
545
545
private module Stage1 implements StageSig {
546
546
class Ap = Unit ;
547
547
548
+ class ApNil = Ap ;
549
+
548
550
private class Cc = boolean ;
549
551
550
552
/* Begin: Stage 1 logic. */
@@ -1297,6 +1299,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
1297
1299
private signature module StageSig {
1298
1300
class Ap ;
1299
1301
1302
+ class ApNil extends Ap ;
1303
+
1300
1304
predicate revFlow ( NodeEx node ) ;
1301
1305
1302
1306
predicate revFlowAp ( NodeEx node , Ap ap ) ;
@@ -1723,6 +1727,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
1723
1727
DataFlowCall call , DataFlowCallable c , ParamNodeEx p , ApApprox apa , boolean emptyAp
1724
1728
) ;
1725
1729
1730
+ private signature predicate flowThroughSig ( ) ;
1731
+
1726
1732
/**
1727
1733
* Exposes the inlined predicate `fwdFlowIn`, which is used to calculate both
1728
1734
* flow in and flow through.
@@ -1731,22 +1737,38 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
1731
1737
* need to record the argument that flows into the parameter.
1732
1738
*
1733
1739
* 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 `,
1735
1741
* which reduces the argument-to-parameter fan-in significantly.
1736
1742
*/
1737
- private module FwdFlowIn< callRestrictionSig / 5 callRestriction > {
1743
+ private module FwdFlowIn< flowThroughSig / 0 flowThrough > {
1738
1744
pragma [ nomagic]
1739
1745
private predicate callEdgeArgParamRestricted (
1740
1746
DataFlowCall call , DataFlowCallable c , ArgNodeEx arg , ParamNodeEx p , boolean emptyAp ,
1741
1747
ApApprox apa
1742
1748
) {
1743
1749
exists ( boolean allowsFieldFlow |
1744
1750
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 ( )
1746
1752
|
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
+ )
1750
1772
)
1751
1773
}
1752
1774
@@ -1876,21 +1898,9 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
1876
1898
}
1877
1899
}
1878
1900
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 ( ) }
1892
1902
1893
- private module FwdFlowInNoThrough = FwdFlowIn< callRestrictionNoFlowThrough / 5 > ;
1903
+ private module FwdFlowInNoThrough = FwdFlowIn< bottom / 0 > ;
1894
1904
1895
1905
pragma [ nomagic]
1896
1906
private predicate fwdFlowInNoFlowThrough (
@@ -1899,21 +1909,9 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
1899
1909
FwdFlowInNoThrough:: fwdFlowIn ( _, _, _, p , state , _, innercc , _, t , ap , apa , _)
1900
1910
}
1901
1911
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 ( ) }
1915
1913
1916
- private module FwdFlowInThrough = FwdFlowIn< callRestrictionFlowThrough / 5 > ;
1914
+ private module FwdFlowInThrough = FwdFlowIn< top / 0 > ;
1917
1915
1918
1916
pragma [ nomagic]
1919
1917
private predicate fwdFlowInFlowThrough (
0 commit comments