@@ -208,16 +208,10 @@ predicate hasNodePath(ControlFlowReachabilityConfiguration conf, ExprNode n1, No
208
208
cfn2 = n2 .( ExprNode ) .getControlFlowNode ( )
209
209
)
210
210
or
211
- exists (
212
- ControlFlow:: Node cfn , AssignableDefinition def , ControlFlow:: Node cfnDef ,
213
- Ssa:: ExplicitDefinition ssaDef
214
- |
215
- conf .hasDefPath ( _, cfn , def , cfnDef )
216
- |
211
+ exists ( ControlFlow:: Node cfn , AssignableDefinition def , ControlFlow:: Node cfnDef |
212
+ conf .hasDefPath ( _, cfn , def , cfnDef ) and
217
213
cfn = n1 .getControlFlowNode ( ) and
218
- ssaDef .getADefinition ( ) = def and
219
- ssaDef .getControlFlowNode ( ) = cfnDef and
220
- n2 .( SsaDefinitionExtNode ) .getDefinitionExt ( ) = ssaDef
214
+ n2 = TAssignableDefinitionNode ( def , cfnDef )
221
215
)
222
216
}
223
217
@@ -544,6 +538,13 @@ module LocalFlow {
544
538
ThisFlow:: adjacentThisRefs ( nodeFrom .( PostUpdateNode ) .getPreUpdateNode ( ) , nodeTo )
545
539
or
546
540
CilFlow:: localFlowStepCil ( nodeFrom , nodeTo )
541
+ or
542
+ exists ( AssignableDefinition def , ControlFlow:: Node cfn , Ssa:: ExplicitDefinition ssaDef |
543
+ ssaDef .getADefinition ( ) = def and
544
+ ssaDef .getControlFlowNode ( ) = cfn and
545
+ nodeFrom = TAssignableDefinitionNode ( def , cfn ) and
546
+ nodeTo .( SsaDefinitionExtNode ) .getDefinitionExt ( ) = ssaDef
547
+ )
547
548
}
548
549
549
550
/**
@@ -599,7 +600,7 @@ module LocalFlow {
599
600
or
600
601
hasNodePath ( any ( LocalExprStepConfiguration x ) , node1 , node2 ) and
601
602
(
602
- node2 instanceof SsaDefinitionExtNode or
603
+ node2 instanceof AssignableDefinitionNode or
603
604
node2 .asExpr ( ) instanceof Cast or
604
605
node2 .asExpr ( ) instanceof AssignExpr
605
606
)
@@ -906,6 +907,11 @@ private module Cached {
906
907
not def .( Ssa:: ExplicitDefinition ) .getADefinition ( ) instanceof
907
908
AssignableDefinitions:: ImplicitParameterDefinition
908
909
} or
910
+ TAssignableDefinitionNode ( AssignableDefinition def , ControlFlow:: Node cfn ) {
911
+ cfn = def .getAControlFlowNode ( ) and
912
+ // Handled by `TExplicitParameterNode` below
913
+ not def instanceof AssignableDefinitions:: ImplicitParameterDefinition
914
+ } or
909
915
TExplicitParameterNode ( DotNet:: Parameter p ) {
910
916
p = any ( DataFlowCallable dfc ) .asCallable ( ) .getAParameter ( )
911
917
} or
@@ -1044,15 +1050,7 @@ import Cached
1044
1050
1045
1051
/** Holds if `n` should be hidden from path explanations. */
1046
1052
predicate nodeIsHidden ( Node n ) {
1047
- exists ( SsaImpl:: DefinitionExt def | def = n .( SsaDefinitionExtNode ) .getDefinitionExt ( ) |
1048
- def instanceof Ssa:: PhiNode
1049
- or
1050
- def instanceof SsaImpl:: PhiReadNode
1051
- or
1052
- def instanceof Ssa:: ImplicitEntryDefinition
1053
- or
1054
- def instanceof Ssa:: ImplicitCallDefinition
1055
- )
1053
+ n instanceof SsaDefinitionExtNode
1056
1054
or
1057
1055
exists ( Parameter p | p = n .( ParameterNode ) .getParameter ( ) | not p .fromSource ( ) )
1058
1056
or
@@ -1080,6 +1078,8 @@ predicate nodeIsHidden(Node n) {
1080
1078
n instanceof InstanceParameterAccessNode
1081
1079
or
1082
1080
n instanceof PrimaryConstructorThisAccessNode
1081
+ or
1082
+ n = any ( AssignableDefinitionNode def | not exists ( def .getDefinition ( ) .getTargetAccess ( ) ) )
1083
1083
}
1084
1084
1085
1085
/** A CIL SSA definition, viewed as a node in a data flow graph. */
@@ -1128,6 +1128,43 @@ class SsaDefinitionExtNode extends NodeImpl, TSsaDefinitionExtNode {
1128
1128
override string toStringImpl ( ) { result = def .toString ( ) }
1129
1129
}
1130
1130
1131
+ /** A definition, viewed as a node in a data flow graph. */
1132
+ class AssignableDefinitionNodeImpl extends NodeImpl , TAssignableDefinitionNode {
1133
+ private AssignableDefinition def ;
1134
+ private ControlFlow:: Node cfn_ ;
1135
+
1136
+ AssignableDefinitionNodeImpl ( ) { this = TAssignableDefinitionNode ( def , cfn_ ) }
1137
+
1138
+ /** Gets the underlying definition. */
1139
+ AssignableDefinition getDefinition ( ) { result = def }
1140
+
1141
+ /** Gets the underlying definition, at control flow node `cfn`, if any. */
1142
+ AssignableDefinition getDefinitionAtNode ( ControlFlow:: Node cfn ) {
1143
+ result = def and
1144
+ cfn = cfn_
1145
+ }
1146
+
1147
+ override DataFlowCallable getEnclosingCallableImpl ( ) {
1148
+ result .asCallable ( ) = cfn_ .getEnclosingCallable ( )
1149
+ }
1150
+
1151
+ override Type getTypeImpl ( ) { result = def .getTarget ( ) .getType ( ) }
1152
+
1153
+ override ControlFlow:: Node getControlFlowNodeImpl ( ) { result = cfn_ }
1154
+
1155
+ override Location getLocationImpl ( ) {
1156
+ result = def .getTargetAccess ( ) .getLocation ( )
1157
+ or
1158
+ not exists ( def .getTargetAccess ( ) ) and result = def .getLocation ( )
1159
+ }
1160
+
1161
+ override string toStringImpl ( ) {
1162
+ result = def .getTargetAccess ( ) .toString ( )
1163
+ or
1164
+ not exists ( def .getTargetAccess ( ) ) and result = def .toString ( )
1165
+ }
1166
+ }
1167
+
1131
1168
abstract class ParameterNodeImpl extends NodeImpl {
1132
1169
abstract predicate isParameterOf ( DataFlowCallable c , ParameterPosition pos ) ;
1133
1170
}
@@ -2021,12 +2058,11 @@ private PropertyContent getResultContent() {
2021
2058
}
2022
2059
2023
2060
private predicate primaryConstructorParameterStore (
2024
- SsaDefinitionExtNode node1 , PrimaryConstructorParameterContent c , Node node2
2061
+ AssignableDefinitionNode node1 , PrimaryConstructorParameterContent c , Node node2
2025
2062
) {
2026
- exists ( Ssa:: ExplicitDefinition def , ControlFlow:: Node cfn , Parameter p |
2027
- def = node1 .getDefinitionExt ( ) and
2028
- p = def .getSourceVariable ( ) .getAssignable ( ) and
2029
- cfn = def .getControlFlowNode ( ) and
2063
+ exists ( AssignableDefinition def , ControlFlow:: Node cfn , Parameter p |
2064
+ node1 = TAssignableDefinitionNode ( def , cfn ) and
2065
+ p = def .getTarget ( ) and
2030
2066
node2 = TInstanceParameterAccessNode ( cfn , true ) and
2031
2067
c .getParameter ( ) = p
2032
2068
)
@@ -2193,18 +2229,16 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
2193
2229
hasNodePath ( x , node1 , node2 )
2194
2230
or
2195
2231
// item = variable in node1 = (..., variable, ...)
2196
- exists ( AssignableDefinitions:: TupleAssignmentDefinition tad , Ssa:: ExplicitDefinition def |
2197
- node2 .( SsaDefinitionExtNode ) .getDefinitionExt ( ) = def and
2198
- def .getADefinition ( ) = tad and
2232
+ exists ( AssignableDefinitions:: TupleAssignmentDefinition tad |
2233
+ node2 .( AssignableDefinitionNode ) .getDefinition ( ) = tad and
2199
2234
tad .getLeaf ( ) = item and
2200
2235
hasNodePath ( x , node1 , node2 )
2201
2236
)
2202
2237
or
2203
2238
// item = variable in node1 = (..., variable, ...) in a case/is var (..., ...)
2204
2239
te = any ( PatternExpr pe ) .getAChildExpr * ( ) and
2205
- exists ( AssignableDefinitions:: LocalVariableDefinition lvd , Ssa:: ExplicitDefinition def |
2206
- node2 .( SsaDefinitionExtNode ) .getDefinitionExt ( ) = def and
2207
- def .getADefinition ( ) = lvd and
2240
+ exists ( AssignableDefinitions:: LocalVariableDefinition lvd |
2241
+ node2 .( AssignableDefinitionNode ) .getDefinition ( ) = lvd and
2208
2242
lvd .getDeclaration ( ) = item and
2209
2243
hasNodePath ( x , node1 , node2 )
2210
2244
)
0 commit comments