mirror of
https://github.com/github/codeql.git
synced 2026-05-13 10:49:26 +02:00
remove redundant inline casts in arguments where the type is inferred by the call target
This commit is contained in:
@@ -25,7 +25,7 @@ class DangerousAssignOpExpr extends AssignOp {
|
||||
}
|
||||
}
|
||||
|
||||
predicate problematicCasting(Type t, Expr e) { e.getType().(NumType).widerThan(t.(NumType)) }
|
||||
predicate problematicCasting(Type t, Expr e) { e.getType().(NumType).widerThan(t) }
|
||||
|
||||
from DangerousAssignOpExpr a, Expr e
|
||||
where
|
||||
|
||||
@@ -14,9 +14,7 @@ private import semmle.code.java.controlflow.internal.GuardsLogic
|
||||
predicate narrowerThanOrEqualTo(ArithExpr exp, NumType numType) {
|
||||
exp.getType().(NumType).widerThan(numType)
|
||||
implies
|
||||
exists(CastExpr cast | cast.getAChildExpr() = exp |
|
||||
numType.widerThanOrEqualTo(cast.getType().(NumType))
|
||||
)
|
||||
exists(CastExpr cast | cast.getAChildExpr() = exp | numType.widerThanOrEqualTo(cast.getType()))
|
||||
}
|
||||
|
||||
private Guard sizeGuard(SsaVariable v, boolean branch, boolean upper) {
|
||||
|
||||
@@ -9,7 +9,7 @@ class NumericNarrowingCastExpr extends CastExpr {
|
||||
exists(NumericType sourceType, NumericType targetType |
|
||||
sourceType = getExpr().getType() and targetType = getType()
|
||||
|
|
||||
not targetType.(NumType).widerThanOrEqualTo(sourceType.(NumType))
|
||||
not targetType.(NumType).widerThanOrEqualTo(sourceType)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user