@@ -957,8 +957,8 @@ module RustDataFlow implements InputSig<Location> {
957
957
/** Holds if path `p` resolves to variant `v`. */
958
958
private predicate pathResolveToVariantCanonicalPath ( PathAstNode p , VariantCanonicalPath v ) {
959
959
exists ( CrateOriginOption crate , string path , string name |
960
- resolveExtendedCanonicalPath ( p , crate , path + "::" + name ) and
961
- v = MkVariantCanonicalPath ( crate , path , name )
960
+ resolveExtendedCanonicalPath ( p , pragma [ only_bind_into ] ( crate ) , path + "::" + name ) and
961
+ v = MkVariantCanonicalPath ( pragma [ only_bind_into ] ( crate ) , path , name )
962
962
)
963
963
}
964
964
@@ -1074,57 +1074,59 @@ module RustDataFlow implements InputSig<Location> {
1074
1074
)
1075
1075
}
1076
1076
1077
+ pragma [ nomagic]
1078
+ private predicate storeContentStep ( Node node1 , Content c , Node node2 ) {
1079
+ exists ( CallExprCfgNode call , int pos |
1080
+ tupleVariantConstruction ( call .getCallExpr ( ) ,
1081
+ c .( VariantPositionContent ) .getVariantCanonicalPath ( pos ) ) and
1082
+ node1 .asExpr ( ) = call .getArgument ( pos ) and
1083
+ node2 .asExpr ( ) = call
1084
+ )
1085
+ or
1086
+ exists ( RecordExprCfgNode re , string field |
1087
+ (
1088
+ // Expression is for a struct-like enum variant.
1089
+ recordVariantConstruction ( re .getRecordExpr ( ) ,
1090
+ c .( VariantFieldContent ) .getVariantCanonicalPath ( field ) )
1091
+ or
1092
+ // Expression is for a struct.
1093
+ structConstruction ( re .getRecordExpr ( ) , c .( StructFieldContent ) .getStructCanonicalPath ( field ) )
1094
+ ) and
1095
+ node1 .asExpr ( ) = re .getFieldExpr ( field ) and
1096
+ node2 .asExpr ( ) = re
1097
+ )
1098
+ or
1099
+ exists ( TupleExprCfgNode tuple |
1100
+ node1 .asExpr ( ) = tuple .getField ( c .( TuplePositionContent ) .getPosition ( ) ) and
1101
+ node2 .asExpr ( ) = tuple
1102
+ )
1103
+ or
1104
+ c instanceof ArrayElementContent and
1105
+ node1 .asExpr ( ) =
1106
+ [
1107
+ node2 .asExpr ( ) .( ArrayRepeatExprCfgNode ) .getRepeatOperand ( ) ,
1108
+ node2 .asExpr ( ) .( ArrayListExprCfgNode ) .getAnExpr ( )
1109
+ ]
1110
+ or
1111
+ tupleAssignment ( node1 , node2 .( PostUpdateNode ) .getPreUpdateNode ( ) , c )
1112
+ or
1113
+ exists ( AssignmentExprCfgNode assignment , IndexExprCfgNode index |
1114
+ c instanceof ArrayElementContent and
1115
+ assignment .getLhs ( ) = index and
1116
+ node1 .asExpr ( ) = assignment .getRhs ( ) and
1117
+ node2 .( PostUpdateNode ) .getPreUpdateNode ( ) .asExpr ( ) = index .getBase ( )
1118
+ )
1119
+ or
1120
+ VariableCapture:: storeStep ( node1 , c , node2 )
1121
+ }
1122
+
1077
1123
/**
1078
1124
* Holds if data can flow from `node1` to `node2` via a store into `c`. Thus,
1079
1125
* `node2` references an object with a content `c.getAStoreContent()` that
1080
1126
* contains the value of `node1`.
1081
1127
*/
1082
1128
predicate storeStep ( Node node1 , ContentSet cs , Node node2 ) {
1083
- exists ( Content c | c = cs .( SingletonContentSet ) .getContent ( ) |
1084
- exists ( CallExprCfgNode call , int pos |
1085
- tupleVariantConstruction ( call .getCallExpr ( ) ,
1086
- c .( VariantPositionContent ) .getVariantCanonicalPath ( pos ) ) and
1087
- node1 .asExpr ( ) = call .getArgument ( pos ) and
1088
- node2 .asExpr ( ) = call
1089
- )
1090
- or
1091
- exists ( RecordExprCfgNode re , string field |
1092
- (
1093
- // Expression is for a struct-like enum variant.
1094
- recordVariantConstruction ( re .getRecordExpr ( ) ,
1095
- c .( VariantFieldContent ) .getVariantCanonicalPath ( field ) )
1096
- or
1097
- // Expression is for a struct.
1098
- structConstruction ( re .getRecordExpr ( ) ,
1099
- c .( StructFieldContent ) .getStructCanonicalPath ( field ) )
1100
- ) and
1101
- node1 .asExpr ( ) = re .getFieldExpr ( field ) and
1102
- node2 .asExpr ( ) = re
1103
- )
1104
- or
1105
- exists ( TupleExprCfgNode tuple |
1106
- node1 .asExpr ( ) = tuple .getField ( c .( TuplePositionContent ) .getPosition ( ) ) and
1107
- node2 .asExpr ( ) = tuple
1108
- )
1109
- or
1110
- c instanceof ArrayElementContent and
1111
- node1 .asExpr ( ) =
1112
- [
1113
- node2 .asExpr ( ) .( ArrayRepeatExprCfgNode ) .getRepeatOperand ( ) ,
1114
- node2 .asExpr ( ) .( ArrayListExprCfgNode ) .getAnExpr ( )
1115
- ]
1116
- or
1117
- tupleAssignment ( node1 , node2 .( PostUpdateNode ) .getPreUpdateNode ( ) , c )
1118
- or
1119
- exists ( AssignmentExprCfgNode assignment , IndexExprCfgNode index |
1120
- c instanceof ArrayElementContent and
1121
- assignment .getLhs ( ) = index and
1122
- node1 .asExpr ( ) = assignment .getRhs ( ) and
1123
- node2 .( PostUpdateNode ) .getPreUpdateNode ( ) .asExpr ( ) = index .getBase ( )
1124
- )
1125
- or
1126
- VariableCapture:: storeStep ( node1 , c , node2 )
1127
- )
1129
+ storeContentStep ( node1 , cs .( SingletonContentSet ) .getContent ( ) , node2 )
1128
1130
or
1129
1131
FlowSummaryImpl:: Private:: Steps:: summaryStoreStep ( node1 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) ,
1130
1132
cs , node2 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) )
0 commit comments