mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
C#: Merge expr_compiler_generated and compiler_generated and add compiler generated statements.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ class Stmt extends ControlFlowElement, @stmt {
|
||||
* For example converts `{ { return x; } }` to `return x;`.
|
||||
*/
|
||||
Stmt stripSingletonBlocks() { result = this }
|
||||
|
||||
/** Holds if this statement is compiler generated. */
|
||||
predicate isCompilerGenerated() { compiler_generated(this) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,7 @@ class Expr extends DotNet::Expr, ControlFlowElement, @expr {
|
||||
* Holds if this expression is generated by the compiler and does not appear
|
||||
* explicitly in the source code.
|
||||
*/
|
||||
predicate isImplicit() { expr_compiler_generated(this) }
|
||||
predicate isImplicit() { compiler_generated(this) }
|
||||
|
||||
/**
|
||||
* Gets an expression that is the result of stripping (recursively) all
|
||||
|
||||
@@ -682,8 +682,6 @@ has_modifiers(
|
||||
int id: @modifiable_direct ref,
|
||||
int mod_id: @modifier ref);
|
||||
|
||||
compiler_generated(unique int id: @modifiable ref);
|
||||
|
||||
/** MEMBERS **/
|
||||
|
||||
@member = @method | @constructor | @destructor | @field | @property | @event | @operator | @indexer | @type;
|
||||
@@ -1271,9 +1269,6 @@ mutator_invocation_mode(
|
||||
unique int id: @operator_invocation_expr ref,
|
||||
int mode: int ref /* prefix = 1, postfix = 2*/);
|
||||
|
||||
expr_compiler_generated(
|
||||
unique int id: @expr ref);
|
||||
|
||||
expr_value(
|
||||
unique int id: @expr ref,
|
||||
string value: string ref);
|
||||
@@ -1316,6 +1311,10 @@ lambda_expr_return_type(
|
||||
unique int id: @lambda_expr ref,
|
||||
int type_id: @type_or_ref ref);
|
||||
|
||||
/* Compiler generated */
|
||||
|
||||
compiler_generated(unique int id: @element ref);
|
||||
|
||||
/** CONTROL/DATA FLOW **/
|
||||
|
||||
@control_flow_element = @stmt | @expr;
|
||||
|
||||
Reference in New Issue
Block a user