Skip to content

Commit d19c832

Browse files
committed
C#: Do not bind comments to compiler generated statements.
1 parent cf9c3d5 commit d19c832

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/Statement`1.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ internal abstract class Statement<TSyntax> : Statement where TSyntax : CSharpSyn
1010
protected readonly TSyntax Stmt;
1111
private readonly Location location;
1212

13-
protected Statement(Context cx, TSyntax stmt, Kinds.StmtKind kind, IStatementParentEntity parent, int child, Location location)
13+
protected Statement(Context cx, TSyntax stmt, Kinds.StmtKind kind, IStatementParentEntity parent, int child, Location location, bool isCompilerGenerated = false)
1414
: base(cx, kind, parent, child)
1515
{
1616
Stmt = stmt;
1717
this.location = location;
18-
cx.BindComments(this, location.Symbol);
18+
if (!isCompilerGenerated)
19+
{
20+
cx.BindComments(this, location.Symbol);
21+
}
1922
}
2023

2124
protected Statement(Context cx, TSyntax stmt, Kinds.StmtKind kind, IStatementParentEntity parent, int child)

csharp/extractor/Semmle.Extraction.CSharp/Entities/Statements/SyntheticEmptyBlock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Semmle.Extraction.CSharp.Entities.Statements
99
internal class SyntheticEmptyBlock : Statement<BlockSyntax>
1010
{
1111
private SyntheticEmptyBlock(Context cx, BlockSyntax block, IStatementParentEntity parent, int child, Location location)
12-
: base(cx, block, StmtKind.BLOCK, parent, child, location) { }
12+
: base(cx, block, StmtKind.BLOCK, parent, child, location, isCompilerGenerated: true) { }
1313

1414
public static SyntheticEmptyBlock Create(Context cx, IStatementParentEntity parent, int child, Location location)
1515
{

0 commit comments

Comments
 (0)