Skip to content

Commit c076992

Browse files
committed
C#: Remove splitting-awareness in ObjectInitializerNode.
1 parent 659d8e7 commit c076992

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

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

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,27 +1825,6 @@ private module OutNodes {
18251825
}
18261826
}
18271827

1828-
class ObjectOrCollectionInitializerConfiguration extends ControlFlowReachabilityConfiguration {
1829-
ObjectOrCollectionInitializerConfiguration() {
1830-
this = "ObjectOrCollectionInitializerConfiguration"
1831-
}
1832-
1833-
override predicate candidate(
1834-
Expr e1, Expr e2, ControlFlowElement scope, boolean exactScope, boolean isSuccessor
1835-
) {
1836-
exactScope = false and
1837-
scope = e1 and
1838-
isSuccessor = true and
1839-
exists(ObjectOrCollectionInitializer init | init = e1.(ObjectCreation).getInitializer() |
1840-
// E.g. `new Dictionary<int, string>{ {0, "a"}, {1, "b"} }`
1841-
e2 = init.(CollectionInitializer).getAnElementInitializer()
1842-
or
1843-
// E.g. `new Dictionary<int, string>() { [0] = "a", [1] = "b" }`
1844-
e2 = init.(ObjectInitializer).getAMemberInitializer().getLValue()
1845-
)
1846-
}
1847-
}
1848-
18491828
/**
18501829
* A data-flow node that reads a value returned by a callable using an
18511830
* `out` or `ref` parameter.
@@ -2672,8 +2651,13 @@ module PostUpdateNodes {
26722651

26732652
override predicate argumentOf(DataFlowCall call, ArgumentPosition pos) {
26742653
pos.isQualifier() and
2675-
any(ObjectOrCollectionInitializerConfiguration x)
2676-
.hasExprPath(_, cfn, _, call.getControlFlowNode())
2654+
exists(ObjectOrCollectionInitializer init | init = oc.getInitializer() |
2655+
// E.g. `new Dictionary<int, string>{ {0, "a"}, {1, "b"} }`
2656+
call.getExpr() = init.(CollectionInitializer).getAnElementInitializer()
2657+
or
2658+
// E.g. `new Dictionary<int, string>() { [0] = "a", [1] = "b" }`
2659+
call.getExpr() = init.(ObjectInitializer).getAMemberInitializer().getLValue()
2660+
)
26772661
}
26782662

26792663
override DataFlowCallable getEnclosingCallableImpl() {

0 commit comments

Comments
 (0)