mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Allow case null, default to be the first switch case
This is consistent with existing treatment of `case null: default:`
This commit is contained in:
@@ -471,6 +471,7 @@ private module ControlFlowGraphImpl {
|
||||
private SwitchCase getASuccessorSwitchCase(PatternCase pred) {
|
||||
result.getParent() = pred.getParent() and
|
||||
result.getIndex() > pred.getIndex() and
|
||||
// Note we do include `case null, default` (as well as plain old `default`) here.
|
||||
not result.(ConstCase).getValue(_) instanceof NullLiteral and
|
||||
(
|
||||
result.getIndex() <= getNextPatternCase(pred).getIndex()
|
||||
@@ -492,6 +493,8 @@ private module ControlFlowGraphImpl {
|
||||
(
|
||||
result.(ConstCase).getValue(_) instanceof NullLiteral
|
||||
or
|
||||
result instanceof NullDefaultCase
|
||||
or
|
||||
not exists(getPatternCase(switch, _))
|
||||
or
|
||||
result.getIndex() <= getPatternCase(switch, 0).getIndex()
|
||||
|
||||
Reference in New Issue
Block a user