Skip to content

Commit

Permalink
C#: Do not calculate field-based SSA for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved committed Aug 30, 2024
1 parent a9b5faa commit 4ef4ede
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ private module SourceVariableImpl {
*/
predicate isPlainFieldOrPropAccess(FieldOrPropAccess fpa, FieldOrProp fp, Callable c) {
fieldOrPropAccessInCallable(fpa, fp, c) and
(ownFieldOrPropAccess(fpa) or fp.isStatic())
(
ownFieldOrPropAccess(fpa)
or
fp.isStatic() and not fp instanceof EnumConstant
)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
| 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: 0 additions & 1 deletion csharp/ql/test/library-tests/dataflow/ssa/SsaDef.expected
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
| 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,7 +89,6 @@
| 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,7 +83,6 @@
| 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: 0 additions & 2 deletions csharp/ql/test/library-tests/dataflow/ssa/SsaRead.expected
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@
| 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,7 +100,6 @@
| 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 4ef4ede

Please sign in to comment.