Skip to content

Commit 1bd504b

Browse files
committed
C#: Restrict CfgScope
1 parent ce2d959 commit 1bd504b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ class CfgScope extends Element, @top_level_exprorstmt_parent {
1515
CfgScope() {
1616
this.getFile().fromSource() and
1717
(
18-
this instanceof Callable
18+
this =
19+
any(Callable c |
20+
c.(Constructor).hasInitializer()
21+
or
22+
InitializerSplitting::constructorInitializes(c, _)
23+
or
24+
c.hasBody()
25+
)
1926
or
2027
// For now, static initializer values have their own scope. Eventually, they
2128
// should be treated like instance initializers.
22-
this.(Assignable).(Modifiable).isStatic()
29+
this.(Assignable).(Modifiable).isStatic() and
30+
expr_parent_top_level_adjusted2(_, _, this)
2331
)
2432
}
2533
}

0 commit comments

Comments
 (0)