mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Unify loop break/continue statement handling between java and kotlin
This commit is contained in:
@@ -1165,17 +1165,6 @@ ktCommentOwners(
|
||||
int owner: @top ref
|
||||
)
|
||||
|
||||
@breakcontinuestmt = @breakstmt
|
||||
| @continuestmt;
|
||||
|
||||
@ktloopstmt = @whilestmt
|
||||
| @dostmt;
|
||||
|
||||
ktBreakContinueTargets(
|
||||
unique int id: @breakcontinuestmt ref,
|
||||
int target: @ktloopstmt ref
|
||||
)
|
||||
|
||||
ktExtensionFunctions(
|
||||
unique int id: @method ref,
|
||||
int typeid: @type ref,
|
||||
|
||||
@@ -888,27 +888,3 @@ class SuperConstructorInvocationStmt extends Stmt, ConstructorCall, @superconstr
|
||||
|
||||
override string getAPrimaryQlClass() { result = "SuperConstructorInvocationStmt" }
|
||||
}
|
||||
|
||||
/** A Kotlin loop statement. */
|
||||
class KtLoopStmt extends Stmt, @ktloopstmt {
|
||||
KtLoopStmt() {
|
||||
this instanceof WhileStmt or
|
||||
this instanceof DoStmt
|
||||
}
|
||||
}
|
||||
|
||||
/** A Kotlin `break` or `continue` statement. */
|
||||
abstract class KtBreakContinueStmt extends Stmt, @breakcontinuestmt {
|
||||
KtLoopStmt loop;
|
||||
|
||||
KtBreakContinueStmt() { ktBreakContinueTargets(this, loop) }
|
||||
|
||||
/** Gets the target loop statement of this `break`. */
|
||||
KtLoopStmt getLoopStmt() { result = loop }
|
||||
}
|
||||
|
||||
/** A Kotlin `break` statement. */
|
||||
class KtBreakStmt extends BreakStmt, KtBreakContinueStmt { }
|
||||
|
||||
/** A Kotlin `continue` statement. */
|
||||
class KtContinueStmt extends ContinueStmt, KtBreakContinueStmt { }
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
breakLabel
|
||||
| stmts.kt:25:24:25:33 | break | loop |
|
||||
continueLabel
|
||||
breakTarget
|
||||
jumpTarget
|
||||
| stmts.kt:25:24:25:33 | break | stmts.kt:23:11:27:5 | while (...) |
|
||||
continueTarget
|
||||
| stmts.kt:29:9:29:16 | continue | stmts.kt:28:5:29:16 | while (...) |
|
||||
|
||||
@@ -4,6 +4,4 @@ query predicate breakLabel(BreakStmt s, string label) { s.getLabel() = label }
|
||||
|
||||
query predicate continueLabel(ContinueStmt s, string label) { s.getLabel() = label }
|
||||
|
||||
query predicate breakTarget(KtBreakStmt s, KtLoopStmt l) { s.getLoopStmt() = l }
|
||||
|
||||
query predicate continueTarget(KtContinueStmt s, KtLoopStmt l) { s.getLoopStmt() = l }
|
||||
query predicate jumpTarget(JumpStmt s, StmtParent p) { s.getTarget() = p }
|
||||
|
||||
@@ -80,6 +80,7 @@ enclosing
|
||||
| stmts.kt:18:52:18:52 | <Expr>; | ExprStmt |
|
||||
| stmts.kt:19:5:19:16 | return ... | ReturnStmt |
|
||||
| stmts.kt:22:27:30:1 | { ... } | BlockStmt |
|
||||
| stmts.kt:23:11:27:5 | <Label>: ... | LabeledStmt |
|
||||
| stmts.kt:23:11:27:5 | while (...) | WhileStmt |
|
||||
| stmts.kt:23:27:27:5 | { ... } | BlockStmt |
|
||||
| stmts.kt:24:9:26:25 | do ... while (...) | DoStmt |
|
||||
|
||||
Reference in New Issue
Block a user