Skip to content

Commit 94079fb

Browse files
committed
C#: Add extractor support for using different expression kinds for NOT expressions.
1 parent 3dedb58 commit 94079fb

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Factory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ internal static Expression Create(ExpressionNodeInfo info)
146146
return Name.Create(info);
147147

148148
case SyntaxKind.LogicalNotExpression:
149-
return PrefixUnary.Create(info.SetKind(ExprKind.LOG_NOT));
149+
return Not.Create(info);
150150

151151
case SyntaxKind.BitwiseNotExpression:
152152
return PrefixUnary.Create(info.SetKind(ExprKind.BIT_NOT));
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.CodeAnalysis;
2+
using Semmle.Extraction.Kinds;
3+
4+
namespace Semmle.Extraction.CSharp.Entities.Expressions
5+
{
6+
internal static class Not
7+
{
8+
public static Expression Create(ExpressionNodeInfo info)
9+
{
10+
var cx = info.Context;
11+
if (cx.GetSymbolInfo(info.Node).Symbol is IMethodSymbol @operator &&
12+
@operator.MethodKind == MethodKind.BuiltinOperator)
13+
{
14+
return PrefixUnary.Create(info.SetKind(ExprKind.LOG_NOT));
15+
}
16+
return PrefixUnary.Create(info.SetKind(ExprKind.NOT));
17+
}
18+
}
19+
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/PrefixUnary.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ private PrefixUnary(ExpressionNodeInfo info)
1111
{
1212
}
1313

14-
1514
public static Expression Create(ExpressionNodeInfo info) => new PrefixUnary(info).TryPopulate();
1615

1716
protected override void PopulateExpression(TextWriter trapFile)

0 commit comments

Comments
 (0)