@@ -173,17 +173,7 @@ class SwitchStmt extends SelectionStmt, @switch_stmt {
173173 * }
174174 * ```
175175 */
176- cached
177- CaseStmt getCase ( int i ) {
178- exists ( int index , int rankIndex |
179- result = getChildStmt ( index ) and
180- rankIndex = i + 1 and
181- index = rank [ rankIndex ] ( int j , CaseStmt cs |
182- cs = this .getChildStmt ( j ) |
183- j
184- )
185- )
186- }
176+ CaseStmt getCase ( int i ) { result = SwithStmtInternal:: getCase ( this , i ) }
187177
188178 /** Gets a case of this `switch` statement. */
189179 CaseStmt getACase ( ) { result = this .getCase ( _) }
@@ -221,29 +211,45 @@ class SwitchStmt extends SelectionStmt, @switch_stmt {
221211 * Note that each non-`default` case is a labeled statement, so the statement
222212 * that follows is a child of the labeled statement, and not the `switch` block.
223213 */
214+ Stmt getStmt ( int i ) { result = SwithStmtInternal:: getStmt ( this , i ) }
215+
216+ /** Gets a statement in the body of this `switch` statement. */
217+ Stmt getAStmt ( ) { result = this .getStmt ( _) }
218+ }
219+
220+ private cached module SwithStmtInternal {
224221 cached
225- Stmt getStmt ( int i ) {
222+ CaseStmt getCase ( SwitchStmt ss , int i ) {
226223 exists ( int index , int rankIndex |
227- result = getChildStmt ( index ) and
224+ result = ss .getChildStmt ( index ) and
225+ rankIndex = i + 1 and
226+ index = rank [ rankIndex ] ( int j , CaseStmt cs |
227+ cs = ss .getChildStmt ( j ) |
228+ j
229+ )
230+ )
231+ }
232+
233+ cached
234+ Stmt getStmt ( SwitchStmt ss , int i ) {
235+ exists ( int index , int rankIndex |
236+ result = ss .getChildStmt ( index ) and
228237 rankIndex = i + 1 and
229238 index = rank [ rankIndex ] ( int j , Stmt s |
230239 // `getChild` includes both labeled statements and the targeted
231240 // statements of labeled statement as separate children, but we
232241 // only want the labeled statement
233- s = getLabeledStmt ( j ) |
242+ s = getLabeledStmt ( ss , j ) |
234243 j
235244 )
236245 )
237246 }
238247
239- private Stmt getLabeledStmt ( int i ) {
240- result = this .getChildStmt ( i ) and
248+ private Stmt getLabeledStmt ( SwitchStmt ss , int i ) {
249+ result = ss .getChildStmt ( i ) and
241250 not result = any ( ConstCase cc ) .getStmt ( ) and
242251 not result = any ( TypeCase tc ) .getStmt ( )
243252 }
244-
245- /** Gets a statement in the body of this `switch` statement. */
246- Stmt getAStmt ( ) { result = this .getStmt ( _) }
247253}
248254
249255/**
0 commit comments