mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
remove redundant cast where the type is enforced by an equality comparison
This commit is contained in:
@@ -31,7 +31,7 @@ class Expr extends StmtParent, @expr {
|
||||
override Stmt getEnclosingStmt() {
|
||||
result = this.getParent().(Expr).getEnclosingStmt()
|
||||
or
|
||||
result = this.getParent().(Stmt)
|
||||
result = this.getParent()
|
||||
or
|
||||
exists(Expr other | result = other.getEnclosingStmt() and other.getConversion() = this)
|
||||
or
|
||||
|
||||
@@ -63,14 +63,14 @@ predicate cannotContainString(Type t) {
|
||||
|
||||
predicate isNonConst(DataFlow::Node node) {
|
||||
exists(Expr e | e = node.asExpr() |
|
||||
exists(FunctionCall fc | fc = e.(FunctionCall) |
|
||||
exists(FunctionCall fc | fc = e |
|
||||
not (
|
||||
whitelistFunction(fc.getTarget(), _) or
|
||||
fc.getTarget().hasDefinition()
|
||||
)
|
||||
)
|
||||
or
|
||||
exists(Parameter p | p = e.(VariableAccess).getTarget().(Parameter) |
|
||||
exists(Parameter p | p = e.(VariableAccess).getTarget() |
|
||||
p.getFunction().getName() = "main" and p.getType() instanceof PointerType
|
||||
)
|
||||
or
|
||||
|
||||
@@ -10,7 +10,7 @@ import semmle.code.cpp.commons.DateTime
|
||||
* Get the top-level `BinaryOperation` enclosing the expression e.
|
||||
*/
|
||||
private BinaryOperation getATopLevelBinaryOperationExpression(Expr e) {
|
||||
result = e.getEnclosingElement().(BinaryOperation)
|
||||
result = e.getEnclosingElement()
|
||||
or
|
||||
result = getATopLevelBinaryOperationExpression(e.getEnclosingElement())
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import cpp
|
||||
from File f, float complexity, float loc
|
||||
where
|
||||
f.fromSource() and
|
||||
loc = sum(FunctionDeclarationEntry fde | fde.getFile() = f | fde.getNumberOfLines()).(float) and
|
||||
loc = sum(FunctionDeclarationEntry fde | fde.getFile() = f | fde.getNumberOfLines()) and
|
||||
if loc > 0
|
||||
then
|
||||
// Weighted average of complexity by function length
|
||||
|
||||
@@ -26,7 +26,7 @@ import cpp
|
||||
from Assignment a, Variable global, Variable local
|
||||
where
|
||||
a.fromSource() and
|
||||
global.getAnAccess() = a.getLValue().(VariableAccess) and
|
||||
global.getAnAccess() = a.getLValue() and
|
||||
local.getAnAccess() = a.getRValue().(AddressOfExpr).getOperand() and
|
||||
local.hasSpecifier("auto") and
|
||||
(
|
||||
|
||||
@@ -49,11 +49,11 @@ class ExposingIntegralUnion extends Union {
|
||||
exists(MemberVariable mv1, MemberVariable mv2, IntegralType mv1tp, IntegralType mv2tp |
|
||||
mv1 = this.getAMemberVariable() and
|
||||
mv2 = this.getAMemberVariable() and
|
||||
mv1tp = mv1.getUnderlyingType().(IntegralType) and
|
||||
mv1tp = mv1.getUnderlyingType() and
|
||||
(
|
||||
mv2tp = mv2.getUnderlyingType().(IntegralType)
|
||||
mv2tp = mv2.getUnderlyingType()
|
||||
or
|
||||
mv2tp = mv2.getUnderlyingType().(ArrayType).getBaseType().getUnderlyingType().(IntegralType)
|
||||
mv2tp = mv2.getUnderlyingType().(ArrayType).getBaseType().getUnderlyingType()
|
||||
) and
|
||||
mv1tp.getSize() > mv2tp.getSize()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user