mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +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()
|
||||
|
||||
@@ -144,6 +144,7 @@
|
||||
| Test.java:55:13:55:25 | (...)... | Test.java:56:8:56:21 | case ... |
|
||||
| Test.java:55:13:55:25 | (...)... | Test.java:58:8:58:21 | case ... |
|
||||
| Test.java:55:13:55:25 | (...)... | Test.java:61:8:61:42 | case T t ... |
|
||||
| Test.java:55:13:55:25 | (...)... | Test.java:69:8:69:26 | case null, default |
|
||||
| Test.java:55:21:55:25 | thing | Test.java:55:13:55:25 | (...)... |
|
||||
| Test.java:56:8:56:21 | case ... | Test.java:57:10:57:44 | <Expr>; |
|
||||
| Test.java:57:10:57:19 | System.out | Test.java:57:29:57:42 | "It's Const1!" |
|
||||
|
||||
Reference in New Issue
Block a user