From 4c9fa4dddc7e9f5759f80709918333ed3ac61def Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Jun 2026 09:37:24 +0000 Subject: [PATCH] Emit catch type mentions without variables --- .../Entities/Statements/Catch.cs | 4 +++- csharp/ql/test/library-tests/regressions/Program.cs | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/csharp/extractor/Semmle.Extraction.CSharp/Entities/Statements/Catch.cs b/csharp/extractor/Semmle.Extraction.CSharp/Entities/Statements/Catch.cs index f3a10f4ef68..30669aae78f 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp/Entities/Statements/Catch.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp/Entities/Statements/Catch.cs @@ -23,7 +23,9 @@ namespace Semmle.Extraction.CSharp.Entities.Statements } else if (isSpecificCatchClause) // A catch clause of the form 'catch(Ex) { ... }' { - trapFile.catch_type(this, Type.Create(Context, Context.GetType(Stmt.Declaration!.Type)).TypeRef, true); + var type = Type.Create(Context, Context.GetType(Stmt.Declaration!.Type)); + trapFile.catch_type(this, type.TypeRef, true); + TypeMention.Create(Context, Stmt.Declaration!.Type, this, type); } else // A catch clause of the form 'catch { ... }' { diff --git a/csharp/ql/test/library-tests/regressions/Program.cs b/csharp/ql/test/library-tests/regressions/Program.cs index dd73876f1a3..38a1afaa5ae 100644 --- a/csharp/ql/test/library-tests/regressions/Program.cs +++ b/csharp/ql/test/library-tests/regressions/Program.cs @@ -50,6 +50,19 @@ class TypeMentions } } +class CatchTypeMentions +{ + void F() + { + try + { + } + catch (Exception) + { + } + } +} + class NameOfMethodGroups { int MethodGroup() => 0;