Fix argument location of top level statement entry point

This commit is contained in:
Tamas Vajk
2021-02-02 09:13:26 +01:00
parent b79d5ab44b
commit 423fee3069
3 changed files with 10 additions and 1 deletions

View File

@@ -112,6 +112,13 @@ namespace Semmle.Extraction.CSharp.Entities
foreach (var l in symbol.Locations)
trapFile.param_location(this, Context.CreateLocation(l));
if (!symbol.Locations.Any() &&
symbol.ContainingSymbol is IMethodSymbol ms &&
ms.Name == WellKnownMemberNames.TopLevelStatementsEntryPointMethodName)
{
trapFile.param_location(this, Context.CreateLocation());
}
if (!IsSourceDeclaration || !symbol.FromSource())
return;

View File

@@ -392,6 +392,8 @@ FunctionPointer.cs:
GlobalStmt.cs:
# 7| [Class] <Program>$
# 7| 4: [Method] <Main>$
#-----| 2: (Parameters)
# 1| 0: [Parameter] args
# 7| 4: [BlockStmt] {...}
# 11| 0: [ExprStmt] ...;
# 11| 0: [MethodCall] call to method WriteLine

View File

@@ -4,7 +4,7 @@ global_stmt
| GlobalStmt.cs:13:1:13:4 | ...; |
| GlobalStmt.cs:15:1:17:1 | M(...) |
globalBlock
| GlobalStmt.cs:7:1:25:1 | {...} | GlobalStmt.cs:7:1:25:1 | <Main>$ | file://:0:0:0:0 | args | GlobalStmt.cs:7:1:25:1 | <Program>$ |
| GlobalStmt.cs:7:1:25:1 | {...} | GlobalStmt.cs:7:1:25:1 | <Main>$ | GlobalStmt.cs:1:1:1:0 | args | GlobalStmt.cs:7:1:25:1 | <Program>$ |
methods
| GlobalStmt.cs:7:1:25:1 | <Main>$ | entry |
| GlobalStmt.cs:21:8:21:9 | M1 | non-entry |