From d7ec468e2e1b49ebed371cddb02f37da3c5dc165 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Jun 2026 12:29:48 +0000 Subject: [PATCH] Add type mentions to control flow element handling --- csharp/ql/lib/semmle/code/csharp/ExprOrStmtParent.qll | 7 +++++++ .../semmle/code/csharp/controlflow/ControlFlowElement.qll | 2 +- csharp/ql/lib/semmlecode.csharp.dbscheme | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/csharp/ql/lib/semmle/code/csharp/ExprOrStmtParent.qll b/csharp/ql/lib/semmle/code/csharp/ExprOrStmtParent.qll index 2cf09707459..ecb17d802be 100644 --- a/csharp/ql/lib/semmle/code/csharp/ExprOrStmtParent.qll +++ b/csharp/ql/lib/semmle/code/csharp/ExprOrStmtParent.qll @@ -121,6 +121,13 @@ private module Cached { result = getAChildExpr(parent) or result = parent.getAChildStmt() + or + result = + any(TypeMention tm | + tm.getTarget() = parent + or + tm.getParent+().getTarget() = parent + ) } private predicate parent(ControlFlowElement child, ExprOrStmtParent parent) { diff --git a/csharp/ql/lib/semmle/code/csharp/controlflow/ControlFlowElement.qll b/csharp/ql/lib/semmle/code/csharp/controlflow/ControlFlowElement.qll index f2b459b63f7..20403f78a86 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/ControlFlowElement.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/ControlFlowElement.qll @@ -20,7 +20,7 @@ class ControlFlowElementOrCallable extends ExprOrStmtParent, TControlFlowElement */ class ControlFlowElement extends ControlFlowElementOrCallable, @control_flow_element { /** Gets the enclosing callable of this element, if any. */ - Callable getEnclosingCallable() { none() } + Callable getEnclosingCallable() { enclosingCallable(this, result) } /** Gets the assembly that this element was compiled into. */ Assembly getAssembly() { diff --git a/csharp/ql/lib/semmlecode.csharp.dbscheme b/csharp/ql/lib/semmlecode.csharp.dbscheme index d13c4c187d7..ddd31efb0e1 100644 --- a/csharp/ql/lib/semmlecode.csharp.dbscheme +++ b/csharp/ql/lib/semmlecode.csharp.dbscheme @@ -1369,7 +1369,7 @@ compiler_generated(unique int id: @element ref); /** CONTROL/DATA FLOW **/ -@control_flow_element = @stmt | @expr | @parameter; +@control_flow_element = @stmt | @expr | @parameter | @type_mention; /* XML Files */