mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
simplify expressions that could be type-casts
This commit is contained in:
@@ -46,7 +46,7 @@ predicate missedAllOpportunity(ForeachStmt fes) {
|
||||
bl = a.getRValue() and
|
||||
bl.toString() = "false"
|
||||
) and
|
||||
exists(BreakStmt bs | bs = is.getThen().getAChild*())
|
||||
is.getThen().getAChild*() instanceof BreakStmt
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
|
||||
XMLAttribute getAttribute(string name) { result.getElement() = this and result.getName() = name }
|
||||
|
||||
/** Holds if this XML element has an attribute with the specified `name`. */
|
||||
predicate hasAttribute(string name) { exists(XMLAttribute a | a = this.getAttribute(name)) }
|
||||
predicate hasAttribute(string name) { exists(this.getAttribute(name)) }
|
||||
|
||||
/** Gets the value of the attribute with the specified `name`, if any. */
|
||||
string getAttributeValue(string name) { result = this.getAttribute(name).getValue() }
|
||||
|
||||
@@ -292,7 +292,7 @@ private module Internal {
|
||||
pragma[nomagic]
|
||||
predicate hasSubsumedQualifierTypeOverridden(Gvn::GvnType t, OverridableCallable c) {
|
||||
this.hasSubsumedQualifierType(t) and
|
||||
hasCallable(t, c, any(OverridableCallable oc | oc = this.getAStaticTargetExt()))
|
||||
hasCallable(t, c, this.getAStaticTargetExt())
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,11 +26,11 @@ Stmt getASuccessorStmt(Stmt s) {
|
||||
}
|
||||
|
||||
class IfThenStmt extends IfStmt {
|
||||
IfThenStmt() { not exists(Stmt s | getElse() = s) }
|
||||
IfThenStmt() { not exists(getElse()) }
|
||||
}
|
||||
|
||||
class IfThenElseStmt extends IfStmt {
|
||||
IfThenElseStmt() { exists(Stmt s | getElse() = s) }
|
||||
IfThenElseStmt() { exists(getElse()) }
|
||||
}
|
||||
|
||||
Stmt getTrailingBody(Stmt s) {
|
||||
|
||||
@@ -24,7 +24,7 @@ class GuardCondition extends Expr {
|
||||
exists(IRGuardCondition ir | this = ir.getUnconvertedResultExpression())
|
||||
or
|
||||
// no binary operators in the IR
|
||||
exists(GuardCondition gc | this.(BinaryLogicalOperation).getAnOperand() = gc)
|
||||
this.(BinaryLogicalOperation).getAnOperand() instanceof GuardCondition
|
||||
or
|
||||
// the IR short-circuits if(!x)
|
||||
// don't produce a guard condition for `y = !x` and other non-short-circuited cases
|
||||
@@ -124,7 +124,7 @@ private predicate impliesValue(
|
||||
*/
|
||||
private class GuardConditionFromBinaryLogicalOperator extends GuardCondition {
|
||||
GuardConditionFromBinaryLogicalOperator() {
|
||||
exists(GuardCondition gc | this.(BinaryLogicalOperation).getAnOperand() = gc)
|
||||
this.(BinaryLogicalOperation).getAnOperand() instanceof GuardCondition
|
||||
}
|
||||
|
||||
override predicate controls(BasicBlock controlled, boolean testIsTrue) {
|
||||
|
||||
Reference in New Issue
Block a user