Skip to content

Commit

Permalink
Merge pull request #17340 from hvitved/csharp/ssa-exclude-enums
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved authored Aug 30, 2024
2 parents 89c387c + 4ef4ede commit 642ec38
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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
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;
}
}

0 comments on commit 642ec38

Please sign in to comment.