simplify lastStatementHasNoEffect and use the control-flow to determine which statement is the last

This commit is contained in:
Erik Krogh Kristensen
2019-10-22 10:33:05 +02:00
parent db22916850
commit ad3185c558

View File

@@ -86,11 +86,7 @@ predicate alwaysThrows(Function f) {
* Holds if the last statement in the function is flagged by the js/useless-expression query.
*/
predicate lastStatementHasNoEffect(Function f) {
exists(DataFlow::Node noEffect |
noEffect.getContainer() = f and
hasNoEffect(noEffect.asExpr()) and
not exists(noEffect.getASuccessor())
)
hasNoEffect(f.getExit().getAPredecessor())
}
predicate callToVoidFunction(DataFlow::CallNode call, Function func) {