mirror of
https://github.com/github/codeql.git
synced 2026-05-04 13:15:21 +02:00
remove redundant inline casts in arguments where the type is inferred by the call target
This commit is contained in:
@@ -567,7 +567,7 @@ class ThrowStmt extends Stmt, @throwstmt {
|
||||
or
|
||||
exists(Stmt mid |
|
||||
mid = this.findEnclosing() and
|
||||
not exists(this.catchClauseForThis(mid.(TryStmt))) and
|
||||
not exists(this.catchClauseForThis(mid)) and
|
||||
result = mid.getEnclosingStmt()
|
||||
)
|
||||
}
|
||||
@@ -575,7 +575,7 @@ class ThrowStmt extends Stmt, @throwstmt {
|
||||
private CatchClause catchClauseForThis(TryStmt try) {
|
||||
result = try.getACatchClause() and
|
||||
result.getEnclosingCallable() = this.getEnclosingCallable() and
|
||||
this.getExpr().getType().(RefType).hasSupertype*(result.getVariable().getType().(RefType)) and
|
||||
this.getExpr().getType().(RefType).hasSupertype*(result.getVariable().getType()) and
|
||||
not this.getEnclosingStmt+() = result
|
||||
}
|
||||
|
||||
|
||||
@@ -511,7 +511,7 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
|
||||
this.getSourceDeclaration().inherits(f)
|
||||
)
|
||||
or
|
||||
this.hasMethod(m.(Method), _)
|
||||
this.hasMethod(m, _)
|
||||
}
|
||||
|
||||
/** Holds if this is a top-level type, which is not nested inside any other types. */
|
||||
|
||||
@@ -299,7 +299,7 @@ Sign exprSign(Expr e) {
|
||||
exists(VarAccess access | access = e |
|
||||
not exists(SsaVariable v | getARead(v) = access) and
|
||||
(
|
||||
s = fieldSign(getField(access.(FieldAccess)))
|
||||
s = fieldSign(getField(access))
|
||||
or
|
||||
anySign(s) and not access instanceof FieldAccess
|
||||
)
|
||||
|
||||
@@ -18,12 +18,12 @@ predicate isLive(Callable c) {
|
||||
* would imply the liveness of `c`.
|
||||
*/
|
||||
Callable possibleLivenessCause(Callable c, string reason) {
|
||||
c.(Method).overridesOrInstantiates(result.(Method)) and
|
||||
c.(Method).overridesOrInstantiates(result) and
|
||||
reason = "is overridden or instantiated by"
|
||||
or
|
||||
result.calls(c) and reason = "calls"
|
||||
or
|
||||
result.callsConstructor(c.(Constructor)) and reason = "calls constructor"
|
||||
result.callsConstructor(c) and reason = "calls constructor"
|
||||
or
|
||||
exists(ClassInstanceExpr e | e.getEnclosingCallable() = result |
|
||||
e.getConstructor() = c and reason = "constructs"
|
||||
@@ -243,7 +243,7 @@ class DeadMethod extends Callable {
|
||||
) and
|
||||
not (
|
||||
this.(Method).isAbstract() and
|
||||
exists(Method m | m.overridesOrInstantiates+(this.(Method)) | isLive(m))
|
||||
exists(Method m | m.overridesOrInstantiates+(this) | isLive(m))
|
||||
) and
|
||||
// A getter or setter associated with a live JPA field.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user