Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a5d50fc

Browse files
committed
C#: Handle in arguments, and add AssignableAccess::isInArgument() predicate.
1 parent cd874f7 commit a5d50fc

11 files changed

Lines changed: 33 additions & 10 deletions

File tree

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expression.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ private void PopulateArgument(ArgumentSyntax arg, int child)
223223
case SyntaxKind.None:
224224
mode = 0;
225225
break;
226+
case SyntaxKind.InKeyword:
227+
mode = 3;
228+
break;
226229
default:
227230
throw new InternalError(arg, "Unknown argument type");
228231
}

csharp/ql/src/semmle/code/csharp/exprs/Access.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ class AssignableAccess extends Access, @assignable_access_expr {
174174
isOutArgument() or
175175
isRefArgument()
176176
}
177+
178+
/**
179+
* Holds if this access passes the assignable being accessed as an `in`
180+
* argument in a method call.
181+
*/
182+
predicate isInArgument() {
183+
expr_argument(this, 3)
184+
}
177185
}
178186

179187
/**
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| csharp72.cs:18:12:18:12 | access to local variable s |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import csharp
2+
3+
from AssignableAccess e
4+
where e.isInArgument()
5+
select e
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| csharp72.cs:42:23:42:34 | 85 |
2-
| csharp72.cs:47:31:47:31 | 1 |
1+
| csharp72.cs:48:23:48:34 | 85 |
2+
| csharp72.cs:53:31:53:31 | 1 |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| csharp72.cs:47:27:47:27 | X |
2-
| csharp72.cs:49:28:49:28 | F |
1+
| csharp72.cs:53:27:53:27 | X |
2+
| csharp72.cs:55:28:55:28 | F |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| csharp72.cs:28:17:28:30 | ReadonlyStruct |
2-
| csharp72.cs:36:21:36:37 | ReadonlyRefStruct |
1+
| csharp72.cs:34:17:34:30 | ReadonlyStruct |
2+
| csharp72.cs:42:21:42:37 | ReadonlyRefStruct |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| csharp72.cs:25:31:25:33 | Del |
1+
| csharp72.cs:31:31:31:33 | Del |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| csharp72.cs:20:22:20:22 | F |
1+
| csharp72.cs:26:22:26:22 | F |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| csharp72.cs:32:12:32:20 | RefStruct |
2-
| csharp72.cs:36:21:36:37 | ReadonlyRefStruct |
1+
| csharp72.cs:38:12:38:20 | RefStruct |
2+
| csharp72.cs:42:21:42:37 | ReadonlyRefStruct |

0 commit comments

Comments
 (0)