Ruby: Remove redundant predicate

The existing barrier guard machinery recognises guards such as `if x and y`,
so there's no need to explicitly model them.
This commit is contained in:
Harry Maclean
2022-11-18 18:14:53 +13:00
parent f24fa402f3
commit 5deb16e58c

View File

@@ -35,8 +35,6 @@ private predicate stringConstCompare(CfgNodes::AstCfgNode guard, CfgNode testedN
stringConstCompareOr(guard, def, branch) and
stringConstCompare(g.getLeftOperand(), testedNode, _)
)
or
stringConstCompareAnd(guard, testedNode, branch)
}
/**
@@ -57,23 +55,6 @@ private predicate stringConstCompareOr(
)
}
/**
* Holds if `guard` is an `and` expression containing a string comparison guard in either operand.
* For example:
*
* ```rb
* x == "foo" and other_condition()
* other_condition() and x == "foo"
* ```
*/
private predicate stringConstCompareAnd(
CfgNodes::ExprNodes::BinaryOperationCfgNode guard, CfgNode testedNode, boolean branch
) {
guard.getExpr() instanceof LogicalAndExpr and
branch = true and
stringConstCompare(guard.getAnOperand(), testedNode, branch)
}
/**
* A validation of value by comparing with a constant string value, for example
* in: