mirror of
https://github.com/github/codeql.git
synced 2026-06-22 21:27:04 +02:00
Merge pull request #22031 from github/copilot/tweak-csharp-extractor
Extract `TypeMention` for `catch (Exception)` clauses
This commit is contained in:
@@ -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 { ... }'
|
||||
{
|
||||
|
||||
@@ -101,6 +101,7 @@ csharp6.cs:
|
||||
# 32| 0: [IntLiteral] 2
|
||||
# 32| 0: [IntLiteral] 1
|
||||
# 34| 1: [SpecificCatchClause] catch (...) {...}
|
||||
# 34| 0: [TypeMention] IndexOutOfRangeException
|
||||
# 35| 1: [BlockStmt] {...}
|
||||
# 34| 2: [EQExpr] ... == ...
|
||||
# 34| 0: [PropertyCall] access to property Value
|
||||
|
||||
@@ -194,3 +194,16 @@ class C3<T> : C2<C4<T>> { }
|
||||
class C4<T> : C2<C3<T>> { }
|
||||
|
||||
class C5 : C4<C5> { }
|
||||
|
||||
class CatchTypeMentions
|
||||
{
|
||||
void F()
|
||||
{
|
||||
try
|
||||
{
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,3 +100,5 @@
|
||||
| Program.cs:194:21:194:21 | T |
|
||||
| Program.cs:196:12:196:17 | C4<C5> |
|
||||
| Program.cs:196:15:196:16 | C5 |
|
||||
| Program.cs:200:5:200:8 | Void |
|
||||
| Program.cs:205:16:205:24 | Exception |
|
||||
|
||||
Reference in New Issue
Block a user