Skip to content

Commit f761a60

Browse files
authored
Merge pull request #4094 from tamasvajk/feature/comp-gen-array-size
C# Compiler generated flag for length arguments of implicitly sized arrays
2 parents f75f5ab + 0cf4c99 commit f761a60

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected ExplicitArrayCreation(ExpressionNodeInfo info) : base(info.SetKind(Exp
1717

1818
protected abstract ArrayTypeSyntax TypeSyntax { get; }
1919

20-
public abstract InitializerExpressionSyntax Initializer { get; }
20+
public abstract InitializerExpressionSyntax Initializer { get; }
2121

2222
protected override void PopulateExpression(TextWriter trapFile)
2323
{
@@ -48,7 +48,7 @@ protected override void PopulateExpression(TextWriter trapFile)
4848
ExprKind.INT_LITERAL,
4949
this,
5050
child,
51-
false,
51+
true,
5252
size.ToString());
5353

5454
new Expression(info);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
| expressions.cs:168:27:168:44 | array creation of type Object[] | expressions.cs:168:27:168:44 | 1 | true |
2+
| expressions.cs:409:23:409:65 | array creation of type Int32[,] | expressions.cs:409:23:409:65 | 3 | true |
3+
| expressions.cs:409:23:409:65 | array creation of type Int32[,] | expressions.cs:409:23:409:65 | 3 | true |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @name Test for array creations
3+
*/
4+
5+
import csharp
6+
7+
private boolean isImplicit(Expr expr) {
8+
if expr.isImplicit() then result = true else result = false
9+
}
10+
11+
from ArrayCreation ac, Expr expr
12+
where ac.isImplicitlySized() and not ac.isImplicitlyTyped() and expr = ac.getALengthArgument()
13+
select ac, expr, isImplicit(expr)

0 commit comments

Comments
 (0)