mirror of
https://github.com/github/codeql.git
synced 2026-04-27 09:45:15 +02:00
Rework global statement extraction without DB scheme change
This commit is contained in:
@@ -51,11 +51,6 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
Overrides(trapFile);
|
||||
ExtractRefReturn(trapFile, symbol, this);
|
||||
ExtractCompilerGenerated(trapFile);
|
||||
|
||||
if (SymbolEqualityComparer.Default.Equals(symbol, Context.Compilation.GetEntryPoint(System.Threading.CancellationToken.None)))
|
||||
{
|
||||
trapFile.entry_methods(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static new OrdinaryMethod Create(Context cx, IMethodSymbol method) => OrdinaryMethodFactory.Instance.CreateEntityFromSymbol(cx, method);
|
||||
|
||||
@@ -7,16 +7,19 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
{
|
||||
internal class GlobalStatementsBlock : Statement
|
||||
{
|
||||
private readonly Method parent;
|
||||
|
||||
private GlobalStatementsBlock(Context cx, Method parent)
|
||||
: base(cx, StmtKind.BLOCK, parent, 0) { }
|
||||
: base(cx, StmtKind.BLOCK, parent, 0)
|
||||
{
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public override Microsoft.CodeAnalysis.Location ReportingLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
// We only create a `GlobalStatementsBlock` if there are global statements. This also means that the
|
||||
// entry point is going to be the generated method around those global statements
|
||||
return cx.Compilation.GetEntryPoint(System.Threading.CancellationToken.None)
|
||||
return parent.symbol
|
||||
?.DeclaringSyntaxReferences
|
||||
.FirstOrDefault()
|
||||
?.GetSyntax()
|
||||
@@ -33,8 +36,6 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
|
||||
|
||||
protected override void PopulateStatement(TextWriter trapFile)
|
||||
{
|
||||
trapFile.global_stmt_block(this);
|
||||
|
||||
trapFile.stmt_location(this, cx.CreateLocation(ReportingLocation));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,11 +379,6 @@ namespace Semmle.Extraction.CSharp
|
||||
trapFile.WriteTuple("methods", method, name, declType, retType, originalDefinition);
|
||||
}
|
||||
|
||||
internal static void entry_methods(this TextWriter trapFile, Method method)
|
||||
{
|
||||
trapFile.WriteTuple("entry_methods", method);
|
||||
}
|
||||
|
||||
internal static void modifiers(this TextWriter trapFile, Label entity, string modifier)
|
||||
{
|
||||
trapFile.WriteTuple("modifiers", entity, modifier);
|
||||
@@ -514,11 +509,6 @@ namespace Semmle.Extraction.CSharp
|
||||
trapFile.WriteTuple("stackalloc_array_creation", array);
|
||||
}
|
||||
|
||||
internal static void global_stmt_block(this TextWriter trapFile, Entities.Statements.GlobalStatementsBlock block)
|
||||
{
|
||||
trapFile.WriteTuple("global_stmt_block", block);
|
||||
}
|
||||
|
||||
internal static void stmt_location(this TextWriter trapFile, Statement stmt, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("stmt_location", stmt, location);
|
||||
|
||||
Reference in New Issue
Block a user