Skip to content

Commit

Permalink
C#: Add SSA test for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved committed Aug 30, 2024
1 parent 123c375 commit a9b5faa
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions csharp/ql/test/library-tests/dataflow/ssa/Enum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
enum E
{
A
}

class EnumTest
{
void M()
{
// enums are modelled as fields; this test checks that we do not compute SSA for them
var e1 = E.A;
var e2 = E.A;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
| DefUse.cs:144:22:144:22 | x | DefUse.cs:146:17:146:17 | access to local variable x | DefUse.cs:147:17:147:17 | access to local variable x |
| DefUse.cs:152:9:152:14 | Field4 | DefUse.cs:156:13:156:18 | access to field Field4 | DefUse.cs:157:13:157:18 | access to field Field4 |
| DefUse.cs:152:9:152:14 | Field4 | DefUse.cs:162:13:162:18 | access to field Field4 | DefUse.cs:163:13:163:18 | access to field Field4 |
| Enum.cs:3:5:3:5 | A | Enum.cs:11:18:11:20 | access to constant A | Enum.cs:12:18:12:20 | access to constant A |
| Example.cs:4:9:4:13 | Field | Example.cs:14:13:14:22 | access to field Field | Example.cs:15:13:15:22 | access to field Field |
| Example.cs:6:23:6:23 | i | Example.cs:8:22:8:22 | access to parameter i | Example.cs:10:13:10:13 | access to parameter i |
| Example.cs:6:23:6:23 | i | Example.cs:10:13:10:13 | access to parameter i | Example.cs:11:26:11:26 | access to parameter i |
Expand Down
1 change: 1 addition & 0 deletions csharp/ql/test/library-tests/dataflow/ssa/SsaDef.expected
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
| DefUse.cs:184:9:184:14 | this.Field5 | DefUse.cs:184:9:184:18 | SSA def(this.Field5) |
| DefUse.cs:184:9:184:14 | this.Field5 | DefUse.cs:191:9:191:11 | SSA call def(this.Field5) |
| DefUse.cs:188:13:188:18 | this.Field5 | DefUse.cs:188:13:188:22 | SSA def(this.Field5) |
| Enum.cs:11:18:11:20 | E.A | Enum.cs:8:10:8:10 | SSA entry def(E.A) |
| Example.cs:6:23:6:23 | i | Example.cs:6:23:6:23 | SSA param(i) |
| Example.cs:8:9:8:18 | this.Field | Example.cs:8:9:8:22 | SSA def(this.Field) |
| Example.cs:8:9:8:18 | this.Field | Example.cs:11:13:11:30 | SSA def(this.Field) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
| DefUse.cs:186:9:190:9 | SSA def(a) | DefUse.cs:186:9:190:9 | ... = ... |
| DefUse.cs:188:13:188:22 | SSA def(this.Field5) | DefUse.cs:188:13:188:22 | ... = ... |
| DefUse.cs:191:9:191:11 | SSA call def(this.Field5) | DefUse.cs:191:9:191:11 | delegate call |
| Enum.cs:8:10:8:10 | SSA entry def(E.A) | Enum.cs:8:10:8:10 | M |
| Example.cs:6:23:6:23 | SSA param(i) | Example.cs:6:23:6:23 | i |
| Example.cs:8:9:8:22 | SSA def(this.Field) | Example.cs:8:9:8:22 | ... = ... |
| Example.cs:11:13:11:30 | SSA def(this.Field) | Example.cs:11:13:11:30 | ... = ... |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
| DefUse.cs:184:9:184:14 | this.Field5 | DefUse.cs:184:9:184:18 | SSA def(this.Field5) | DefUse.cs:185:13:185:18 | access to field Field5 |
| DefUse.cs:184:9:184:14 | this.Field5 | DefUse.cs:191:9:191:11 | SSA call def(this.Field5) | DefUse.cs:192:13:192:18 | access to field Field5 |
| DefUse.cs:188:13:188:18 | this.Field5 | DefUse.cs:188:13:188:22 | SSA def(this.Field5) | DefUse.cs:189:17:189:22 | access to field Field5 |
| Enum.cs:11:18:11:20 | E.A | Enum.cs:8:10:8:10 | SSA entry def(E.A) | Enum.cs:12:18:12:20 | access to constant A |
| Example.cs:6:23:6:23 | i | Example.cs:6:23:6:23 | SSA param(i) | Example.cs:11:26:11:26 | access to parameter i |
| Example.cs:6:23:6:23 | i | Example.cs:6:23:6:23 | SSA param(i) | Example.cs:12:18:12:18 | access to parameter i |
| Example.cs:8:9:8:18 | this.Field | Example.cs:8:9:8:22 | SSA def(this.Field) | Example.cs:9:13:9:22 | access to field Field |
Expand Down
2 changes: 2 additions & 0 deletions csharp/ql/test/library-tests/dataflow/ssa/SsaRead.expected
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
| DefUse.cs:184:9:184:14 | this.Field5 | DefUse.cs:184:9:184:18 | SSA def(this.Field5) | DefUse.cs:185:13:185:18 | access to field Field5 |
| DefUse.cs:184:9:184:14 | this.Field5 | DefUse.cs:191:9:191:11 | SSA call def(this.Field5) | DefUse.cs:192:13:192:18 | access to field Field5 |
| DefUse.cs:188:13:188:18 | this.Field5 | DefUse.cs:188:13:188:22 | SSA def(this.Field5) | DefUse.cs:189:17:189:22 | access to field Field5 |
| Enum.cs:11:18:11:20 | E.A | Enum.cs:8:10:8:10 | SSA entry def(E.A) | Enum.cs:11:18:11:20 | access to constant A |
| Enum.cs:11:18:11:20 | E.A | Enum.cs:8:10:8:10 | SSA entry def(E.A) | Enum.cs:12:18:12:20 | access to constant A |
| Example.cs:6:23:6:23 | i | Example.cs:6:23:6:23 | SSA param(i) | Example.cs:8:22:8:22 | access to parameter i |
| Example.cs:6:23:6:23 | i | Example.cs:6:23:6:23 | SSA param(i) | Example.cs:10:13:10:13 | access to parameter i |
| Example.cs:6:23:6:23 | i | Example.cs:6:23:6:23 | SSA param(i) | Example.cs:11:26:11:26 | access to parameter i |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
| DefUse.cs:184:9:184:14 | this.Field5 | DefUse.cs:191:9:191:11 | SSA call def(this.Field5) | DefUse.cs:184:9:184:18 | SSA def(this.Field5) |
| DefUse.cs:184:9:184:14 | this.Field5 | DefUse.cs:191:9:191:11 | SSA call def(this.Field5) | DefUse.cs:191:9:191:11 | SSA call def(this.Field5) |
| DefUse.cs:188:13:188:18 | this.Field5 | DefUse.cs:188:13:188:22 | SSA def(this.Field5) | DefUse.cs:188:13:188:22 | SSA def(this.Field5) |
| Enum.cs:11:18:11:20 | E.A | Enum.cs:8:10:8:10 | SSA entry def(E.A) | Enum.cs:8:10:8:10 | SSA entry def(E.A) |
| Example.cs:6:23:6:23 | i | Example.cs:6:23:6:23 | SSA param(i) | Example.cs:6:23:6:23 | SSA param(i) |
| Example.cs:8:9:8:18 | this.Field | Example.cs:8:9:8:22 | SSA def(this.Field) | Example.cs:8:9:8:22 | SSA def(this.Field) |
| Example.cs:8:9:8:18 | this.Field | Example.cs:11:13:11:30 | SSA def(this.Field) | Example.cs:11:13:11:30 | SSA def(this.Field) |
Expand Down

0 comments on commit a9b5faa

Please sign in to comment.