@@ -1022,6 +1022,32 @@ final class SingletonContentSet extends ContentSet, TSingletonContentSet {
10221022 override Content getAReadContent ( ) { result = c }
10231023}
10241024
1025+ final class OptionalStep extends ContentSet , TOptionalStep {
1026+ override string toString ( ) {
1027+ exists ( string name |
1028+ this = TOptionalStep ( name ) and
1029+ result = "OptionalStep[" + name + "]"
1030+ )
1031+ }
1032+
1033+ override Content getAStoreContent ( ) { none ( ) }
1034+
1035+ override Content getAReadContent ( ) { none ( ) }
1036+ }
1037+
1038+ final class OptionalBarrier extends ContentSet , TOptionalBarrier {
1039+ override string toString ( ) {
1040+ exists ( string name |
1041+ this = TOptionalBarrier ( name ) and
1042+ result = "OptionalBarrier[" + name + "]"
1043+ )
1044+ }
1045+
1046+ override Content getAStoreContent ( ) { none ( ) }
1047+
1048+ override Content getAReadContent ( ) { none ( ) }
1049+ }
1050+
10251051class LambdaCallKind = Unit ;
10261052
10271053/** Holds if `creation` is an expression that creates a lambda of kind `kind`. */
@@ -1222,6 +1248,12 @@ module RustDataFlow implements InputSig<Location> {
12221248 model = ""
12231249 or
12241250 LocalFlow:: flowSummaryLocalStep ( nodeFrom , nodeTo , model )
1251+ or
1252+ // Add flow through optional barriers. This step is then blocked by the barrier for queries that choose to use the barrier.
1253+ FlowSummaryImpl:: Private:: Steps:: summaryReadStep ( nodeFrom
1254+ .( Node:: FlowSummaryNode )
1255+ .getSummaryNode ( ) , TOptionalBarrier ( _) , nodeTo .( Node:: FlowSummaryNode ) .getSummaryNode ( ) ) and
1256+ model = ""
12251257 }
12261258
12271259 /**
@@ -1353,7 +1385,8 @@ module RustDataFlow implements InputSig<Location> {
13531385 )
13541386 or
13551387 FlowSummaryImpl:: Private:: Steps:: summaryReadStep ( node1 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) ,
1356- cs , node2 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) )
1388+ cs , node2 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) ) and
1389+ not isSpecialContentSet ( cs )
13571390 }
13581391
13591392 pragma [ nomagic]
@@ -1450,7 +1483,8 @@ module RustDataFlow implements InputSig<Location> {
14501483 storeContentStep ( node1 , cs .( SingletonContentSet ) .getContent ( ) , node2 )
14511484 or
14521485 FlowSummaryImpl:: Private:: Steps:: summaryStoreStep ( node1 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) ,
1453- cs , node2 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) )
1486+ cs , node2 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) ) and
1487+ not isSpecialContentSet ( cs )
14541488 }
14551489
14561490 /**
@@ -1794,7 +1828,24 @@ private module Cached {
17941828 TReferenceContent ( )
17951829
17961830 cached
1797- newtype TContentSet = TSingletonContentSet ( Content c )
1831+ newtype TContentSet =
1832+ TSingletonContentSet ( Content c ) or
1833+ TOptionalStep ( string name ) {
1834+ name = any ( FlowSummaryImpl:: Private:: AccessPathToken tok ) .getAnArgument ( "OptionalStep" )
1835+ } or
1836+ TOptionalBarrier ( string name ) {
1837+ name = any ( FlowSummaryImpl:: Private:: AccessPathToken tok ) .getAnArgument ( "OptionalBarrier" )
1838+ }
1839+
1840+ /**
1841+ * Holds if `cs` is used to encode a special operation as a content component, but should not
1842+ * be treated as an ordinary content component.
1843+ */
1844+ cached
1845+ predicate isSpecialContentSet ( ContentSet cs ) {
1846+ cs instanceof TOptionalStep or
1847+ cs instanceof TOptionalBarrier
1848+ }
17981849
17991850 /** Holds if `n` is a flow source of kind `kind`. */
18001851 cached
@@ -1806,3 +1857,22 @@ private module Cached {
18061857}
18071858
18081859import Cached
1860+
1861+ cached
1862+ private module OptionalSteps {
1863+ cached
1864+ predicate optionalStep ( Node node1 , string name , Node node2 ) {
1865+ FlowSummaryImpl:: Private:: Steps:: summaryReadStep ( node1 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) ,
1866+ TOptionalStep ( name ) , node2 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) ) or
1867+ FlowSummaryImpl:: Private:: Steps:: summaryStoreStep ( node1 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) ,
1868+ TOptionalStep ( name ) , node2 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) )
1869+ }
1870+
1871+ cached
1872+ predicate optionalBarrier ( Node node , string name ) {
1873+ FlowSummaryImpl:: Private:: Steps:: summaryReadStep ( _, TOptionalBarrier ( name ) ,
1874+ node .( Node:: FlowSummaryNode ) .getSummaryNode ( ) )
1875+ }
1876+ }
1877+
1878+ import OptionalSteps
0 commit comments