Skip to content

Commit 6f3bff1

Browse files
committed
Expose getFirstPatternCase, not getPatternCase/2
1 parent 40464ed commit 6f3bff1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

java/ql/lib/semmle/code/java/ControlFlowGraph.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,9 @@ private module ControlFlowGraphImpl {
478478
or
479479
result instanceof NullDefaultCase
480480
or
481-
not exists(getPatternCase(switch, _))
481+
not exists(getFirstPatternCase(switch))
482482
or
483-
result.getIndex() <= getPatternCase(switch, 0).getIndex()
483+
result.getIndex() <= getFirstPatternCase(switch).getIndex()
484484
)
485485
}
486486

java/ql/lib/semmle/code/java/controlflow/internal/SwitchCases.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ import java
55
/**
66
* Gets the `i`th `PatternCase` defined on `switch`, if one exists.
77
*/
8-
PatternCase getPatternCase(StmtParent switch, int i) {
8+
private PatternCase getPatternCase(StmtParent switch, int i) {
99
result =
1010
rank[i + 1](PatternCase pc, int caseIdx | pc.isNthCaseOf(switch, caseIdx) | pc order by caseIdx)
1111
}
1212

13+
/**
14+
* Gets the first `PatternCase` defined on `switch`, if one exists.
15+
*/
16+
PatternCase getFirstPatternCase(StmtParent switch) {
17+
result = getPatternCase(switch, 0)
18+
}
19+
1320
/**
1421
* Gets the PatternCase after pc, if one exists.
1522
*/

0 commit comments

Comments
 (0)