mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
Java: Make JumpStmt a proper superclass
This commit is contained in:
@@ -16,6 +16,6 @@ import java
|
||||
from DoStmt do, ContinueStmt continue
|
||||
where
|
||||
do.getCondition().(BooleanLiteral).getBooleanValue() = false and
|
||||
continue.(JumpStmt).getTarget() = do
|
||||
continue.getTarget() = do
|
||||
select continue, "This 'continue' never re-runs the loop - the $@ is always false.",
|
||||
do.getCondition(), "loop condition"
|
||||
|
||||
@@ -32,7 +32,7 @@ predicate loopExit(LoopStmt loop, Stmt exit) {
|
||||
exit.getEnclosingStmt*() = loop.getBody() and
|
||||
(
|
||||
exit instanceof ReturnStmt or
|
||||
exit.(BreakStmt).(JumpStmt).getTarget() = loop.getEnclosingStmt*()
|
||||
exit.(BreakStmt).getTarget() = loop.getEnclosingStmt*()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user