Skip to content

Commit 7bdc2c5

Browse files
committed
C#: Simplify primaryConstructorParameterStore
1 parent 3f43f45 commit 7bdc2c5

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,24 +2023,14 @@ private PropertyContent getResultContent() {
20232023
}
20242024

20252025
private predicate primaryConstructorParameterStore(
2026-
Node node1, PrimaryConstructorParameterContent c, Node node2
2026+
SsaDefinitionExtNode node1, PrimaryConstructorParameterContent c, Node node2
20272027
) {
2028-
exists(ControlFlow::Node cfn, Parameter p |
2028+
exists(Ssa::ExplicitDefinition def, ControlFlow::Node cfn, Parameter p |
2029+
def = node1.getDefinitionExt() and
2030+
p = def.getSourceVariable().getAssignable() and
2031+
cfn = def.getControlFlowNode() and
20292032
node2 = TInstanceParameterAccessNode(cfn, true) and
20302033
c.getParameter() = p
2031-
|
2032-
// direct assignment
2033-
exists(LocalFlow::LocalExprStepConfiguration conf, AssignableDefinition def |
2034-
conf.hasDefPath(_, node1.(ExprNode).getControlFlowNode(), def, cfn) and
2035-
p = def.getTarget()
2036-
)
2037-
or
2038-
// indirect assignment (for example as an `out` argument)
2039-
exists(Ssa::ExplicitDefinition def |
2040-
def = node1.(SsaDefinitionExtNode).getDefinitionExt() and
2041-
p = def.getSourceVariable().getAssignable() and
2042-
cfn = def.getControlFlowNode()
2043-
)
20442034
)
20452035
}
20462036

csharp/ql/test/library-tests/dataflow/constructors/ConstructorFlow.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ edges
2020
| Constructors.cs:50:32:50:36 | this : C2 [field Obj21] : Object | Constructors.cs:50:32:50:36 | this access : C2 [field Obj21] : Object | provenance | |
2121
| Constructors.cs:50:32:50:36 | this access : C2 [field Obj21] : Object | Constructors.cs:50:32:50:36 | access to field Obj21 : Object | provenance | |
2222
| Constructors.cs:52:35:52:35 | o : Object | Constructors.cs:54:13:54:24 | SSA def(o22param) : Object | provenance | |
23-
| Constructors.cs:52:35:52:35 | o : Object | Constructors.cs:54:24:54:24 | access to parameter o : Object | provenance | |
2423
| Constructors.cs:57:54:57:55 | o2 : Object | Constructors.cs:59:13:59:19 | SSA def(o1) : Object | provenance | |
2524
| Constructors.cs:62:41:62:41 | o : Object | Constructors.cs:64:37:64:37 | access to parameter o : Object | provenance | |
2625
| Constructors.cs:64:37:64:37 | access to parameter o : Object | Constructors.cs:57:54:57:55 | o2 : Object | provenance | |
@@ -85,7 +84,6 @@ nodes
8584
| Constructors.cs:50:32:50:36 | this access : C2 [field Obj21] : Object | semmle.label | this access : C2 [field Obj21] : Object |
8685
| Constructors.cs:52:35:52:35 | o : Object | semmle.label | o : Object |
8786
| Constructors.cs:54:13:54:24 | SSA def(o22param) : Object | semmle.label | SSA def(o22param) : Object |
88-
| Constructors.cs:54:24:54:24 | access to parameter o : Object | semmle.label | access to parameter o : Object |
8987
| Constructors.cs:57:54:57:55 | o2 : Object | semmle.label | o2 : Object |
9088
| Constructors.cs:59:13:59:19 | SSA def(o1) : Object | semmle.label | SSA def(o1) : Object |
9189
| Constructors.cs:62:41:62:41 | o : Object | semmle.label | o : Object |
@@ -126,7 +124,6 @@ subpaths
126124
| Constructors.cs:81:14:81:15 | access to local variable c2 : C2 [parameter o22param] : Object | Constructors.cs:48:32:48:39 | this : C2 [parameter o22param] : Object | Constructors.cs:48:32:48:39 | access to parameter o22param : Object | Constructors.cs:81:14:81:21 | access to property Obj22 |
127125
| Constructors.cs:82:14:82:15 | access to local variable c2 : C2 [field Obj21] : Object | Constructors.cs:50:32:50:36 | this : C2 [field Obj21] : Object | Constructors.cs:50:32:50:36 | access to field Obj21 : Object | Constructors.cs:82:14:82:21 | access to property Obj23 |
128126
| Constructors.cs:92:19:92:23 | access to local variable taint : Object | Constructors.cs:52:35:52:35 | o : Object | Constructors.cs:54:13:54:24 | SSA def(o22param) : Object | Constructors.cs:92:9:92:10 | [post] access to local variable c2 : C2 [parameter o22param] : Object |
129-
| Constructors.cs:92:19:92:23 | access to local variable taint : Object | Constructors.cs:52:35:52:35 | o : Object | Constructors.cs:54:24:54:24 | access to parameter o : Object | Constructors.cs:92:9:92:10 | [post] access to local variable c2 : C2 [parameter o22param] : Object |
130127
| Constructors.cs:93:14:93:15 | access to local variable c2 : C2 [parameter o22param] : Object | Constructors.cs:48:32:48:39 | this : C2 [parameter o22param] : Object | Constructors.cs:48:32:48:39 | access to parameter o22param : Object | Constructors.cs:93:14:93:21 | access to property Obj22 |
131128
| Constructors.cs:100:25:100:29 | access to local variable taint : Object | Constructors.cs:62:41:62:41 | o : Object | Constructors.cs:64:27:64:34 | SSA def(o22param) : Object | Constructors.cs:100:9:100:10 | [post] access to local variable c2 : C2 [parameter o22param] : Object |
132129
| Constructors.cs:101:14:101:15 | access to local variable c2 : C2 [parameter o22param] : Object | Constructors.cs:48:32:48:39 | this : C2 [parameter o22param] : Object | Constructors.cs:48:32:48:39 | access to parameter o22param : Object | Constructors.cs:101:14:101:21 | access to property Obj22 |

0 commit comments

Comments
 (0)