Merge pull request #8582 from Marcono1234/marcono1234/JumpStmt-superclass

Java: Make `JumpStmt` a proper superclass
This commit is contained in:
Anders Schack-Mulligen
2022-04-25 12:22:20 +02:00
committed by GitHub
11 changed files with 67 additions and 21 deletions

View File

@@ -44,11 +44,11 @@ class PointlessLoop extends WhileStmt {
PointlessLoop() {
this.getCondition().(BooleanLiteral).getBooleanValue() = true and
// The only `break` must be the last statement.
forall(BreakStmt break | break.(JumpStmt).getTarget() = this |
forall(BreakStmt break | break.getTarget() = this |
this.getStmt().(BlockStmt).getLastStmt() = break
) and
// No `continue` statements.
not exists(ContinueStmt continue | continue.(JumpStmt).getTarget() = this)
not exists(ContinueStmt continue | continue.getTarget() = this)
}
}

View File

@@ -26,7 +26,7 @@ predicate loopCondition(LoopStmt loop, Expr cond, boolean polarity) {
ifstmt.getEnclosingStmt*() = loop.getBody() and
ifstmt.getCondition() = cond and
(
exit.(BreakStmt).(JumpStmt).getTarget() = loop or
exit.(BreakStmt).getTarget() = loop or
exit.(ReturnStmt).getEnclosingStmt*() = loop.getBody()
) and
(