From c076992b83affe0fd18e9f42b6f3576178a47479 Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Fri, 13 Mar 2026 13:31:53 +0100 Subject: [PATCH] C#: Remove splitting-awareness in ObjectInitializerNode. --- .../dataflow/internal/DataFlowPrivate.qll | 30 +++++-------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll index 2237f3e5954..232b765c68a 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll @@ -1825,27 +1825,6 @@ private module OutNodes { } } - class ObjectOrCollectionInitializerConfiguration extends ControlFlowReachabilityConfiguration { - ObjectOrCollectionInitializerConfiguration() { - this = "ObjectOrCollectionInitializerConfiguration" - } - - override predicate candidate( - Expr e1, Expr e2, ControlFlowElement scope, boolean exactScope, boolean isSuccessor - ) { - exactScope = false and - scope = e1 and - isSuccessor = true and - exists(ObjectOrCollectionInitializer init | init = e1.(ObjectCreation).getInitializer() | - // E.g. `new Dictionary{ {0, "a"}, {1, "b"} }` - e2 = init.(CollectionInitializer).getAnElementInitializer() - or - // E.g. `new Dictionary() { [0] = "a", [1] = "b" }` - e2 = init.(ObjectInitializer).getAMemberInitializer().getLValue() - ) - } - } - /** * A data-flow node that reads a value returned by a callable using an * `out` or `ref` parameter. @@ -2672,8 +2651,13 @@ module PostUpdateNodes { override predicate argumentOf(DataFlowCall call, ArgumentPosition pos) { pos.isQualifier() and - any(ObjectOrCollectionInitializerConfiguration x) - .hasExprPath(_, cfn, _, call.getControlFlowNode()) + exists(ObjectOrCollectionInitializer init | init = oc.getInitializer() | + // E.g. `new Dictionary{ {0, "a"}, {1, "b"} }` + call.getExpr() = init.(CollectionInitializer).getAnElementInitializer() + or + // E.g. `new Dictionary() { [0] = "a", [1] = "b" }` + call.getExpr() = init.(ObjectInitializer).getAMemberInitializer().getLValue() + ) } override DataFlowCallable getEnclosingCallableImpl() {