C#: Merge expr_compiler_generated and compiler_generated and add compiler generated statements.

This commit is contained in:
Michael Nebel
2024-02-22 15:31:07 +01:00
parent 606a8fed0c
commit bf4e3a7d1c
6 changed files with 16 additions and 10 deletions

View File

@@ -54,7 +54,7 @@ namespace Semmle.Extraction.CSharp.Entities
}
if (info.IsCompilerGenerated)
trapFile.expr_compiler_generated(this);
trapFile.compiler_generated(this);
if (info.ExprValue is string value)
trapFile.expr_value(this, value);

View File

@@ -9,12 +9,14 @@ namespace Semmle.Extraction.CSharp.Entities
{
protected readonly TSyntax Stmt;
private readonly Location location;
private readonly bool isCompilerGenerated;
protected Statement(Context cx, TSyntax stmt, Kinds.StmtKind kind, IStatementParentEntity parent, int child, Location location, bool isCompilerGenerated = false)
: base(cx, kind, parent, child)
{
Stmt = stmt;
this.location = location;
this.isCompilerGenerated = isCompilerGenerated;
if (!isCompilerGenerated)
{
cx.BindComments(this, location.Symbol);
@@ -29,6 +31,11 @@ namespace Semmle.Extraction.CSharp.Entities
base.Populate(trapFile);
trapFile.stmt_location(this, location);
if (isCompilerGenerated)
{
trapFile.compiler_generated(this);
}
}
public override Microsoft.CodeAnalysis.Location ReportingLocation => Stmt.GetLocation();

View File

@@ -164,9 +164,6 @@ namespace Semmle.Extraction.CSharp
internal static void expr_call(this TextWriter trapFile, Expression expr, Method target) =>
trapFile.WriteTuple("expr_call", expr, target);
internal static void expr_compiler_generated(this TextWriter trapFile, Expression expr) =>
trapFile.WriteTuple("expr_compiler_generated", expr);
internal static void expr_flowstate(this TextWriter trapFile, Expression expr, int flowState) =>
trapFile.WriteTuple("expr_flowstate", expr, flowState);