Java: Simplify own member access checks

This commit is contained in:
Marcono1234
2021-03-04 22:45:52 +01:00
parent 178c54e69b
commit c8315577fe
6 changed files with 9 additions and 39 deletions

View File

@@ -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)
)

View File

@@ -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