mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
Java: Change TCs of Stmt.getParent to Stmt.getEnclosingStmt.
This commit is contained in:
committed by
yh-semmle
parent
6ecf46ce85
commit
0a569f6c1a
@@ -48,7 +48,7 @@ predicate useAndDef(Assignment a, Variable v) {
|
||||
predicate declaredInLoop(LocalVariableDecl v, LoopStmt loop) {
|
||||
exists(LocalVariableDeclExpr e |
|
||||
e.getVariable() = v and
|
||||
e.getEnclosingStmt().getParent*() = loop.getBody()
|
||||
e.getEnclosingStmt().getEnclosingStmt*() = loop.getBody()
|
||||
)
|
||||
or
|
||||
exists(EnhancedForStmt for | for = loop | for.getVariable().getVariable() = v)
|
||||
@@ -57,5 +57,5 @@ predicate declaredInLoop(LocalVariableDecl v, LoopStmt loop) {
|
||||
from Assignment a, Variable v
|
||||
where
|
||||
useAndDef(a, v) and
|
||||
exists(LoopStmt loop | a.getEnclosingStmt().getParent*() = loop | not declaredInLoop(v, loop))
|
||||
exists(LoopStmt loop | a.getEnclosingStmt().getEnclosingStmt*() = loop | not declaredInLoop(v, loop))
|
||||
select a, "The string " + v.getName() + " is built-up in a loop: use string buffer."
|
||||
|
||||
Reference in New Issue
Block a user