simplify expressions that could be type-casts

This commit is contained in:
Erik Krogh Kristensen
2022-01-20 10:41:35 +01:00
parent 547f492be0
commit 4e8e3a7420
70 changed files with 123 additions and 143 deletions

View File

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

View File

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

View File

@@ -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())
}
/**

View File

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

View File

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