@@ -1022,6 +1022,32 @@ final class SingletonContentSet extends ContentSet, TSingletonContentSet {
1022
1022
override Content getAReadContent ( ) { result = c }
1023
1023
}
1024
1024
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
+
1025
1051
class LambdaCallKind = Unit ;
1026
1052
1027
1053
/** Holds if `creation` is an expression that creates a lambda of kind `kind`. */
@@ -1222,6 +1248,12 @@ module RustDataFlow implements InputSig<Location> {
1222
1248
model = ""
1223
1249
or
1224
1250
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 = ""
1225
1257
}
1226
1258
1227
1259
/**
@@ -1353,7 +1385,8 @@ module RustDataFlow implements InputSig<Location> {
1353
1385
)
1354
1386
or
1355
1387
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 )
1357
1390
}
1358
1391
1359
1392
pragma [ nomagic]
@@ -1450,7 +1483,8 @@ module RustDataFlow implements InputSig<Location> {
1450
1483
storeContentStep ( node1 , cs .( SingletonContentSet ) .getContent ( ) , node2 )
1451
1484
or
1452
1485
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 )
1454
1488
}
1455
1489
1456
1490
/**
@@ -1794,7 +1828,24 @@ private module Cached {
1794
1828
TReferenceContent ( )
1795
1829
1796
1830
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
+ }
1798
1849
1799
1850
/** Holds if `n` is a flow source of kind `kind`. */
1800
1851
cached
@@ -1806,3 +1857,22 @@ private module Cached {
1806
1857
}
1807
1858
1808
1859
import 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