mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
Java: Simplify own member access checks
This commit is contained in:
@@ -47,10 +47,7 @@ private predicate nonChainingReturn(Method m, ReturnStmt ret) {
|
||||
not hasSubtype*(m.getReturnType(), delegate.getReturnType())
|
||||
or
|
||||
// A method on the wrong object is called.
|
||||
not (
|
||||
delegateCall.getQualifier() instanceof ThisAccess or
|
||||
not exists(delegateCall.getQualifier())
|
||||
)
|
||||
not delegateCall.isOwnMethodAccess()
|
||||
or
|
||||
nonChaining(delegate)
|
||||
)
|
||||
|
||||
@@ -50,17 +50,10 @@ class EmptyLoop extends Stmt {
|
||||
}
|
||||
}
|
||||
|
||||
/** An access to a field in this object. */
|
||||
class FieldAccessInThis extends VarAccess {
|
||||
FieldAccessInThis() {
|
||||
this.getVariable() instanceof Field and
|
||||
(not this.hasQualifier() or this.getQualifier() instanceof ThisAccess)
|
||||
}
|
||||
}
|
||||
|
||||
from EmptyLoop loop, FieldAccessInThis access, Field field, ComparisonOrEqTestExpr expr
|
||||
from EmptyLoop loop, FieldAccess access, Field field, ComparisonOrEqTestExpr expr
|
||||
where
|
||||
loop.getCondition() = expr and
|
||||
access.isOwnFieldAccess() and
|
||||
access.getParent() = expr and
|
||||
field = access.getVariable() and
|
||||
field.isStatic() and
|
||||
|
||||
Reference in New Issue
Block a user