Skip to content

Commit db22916

Browse files
committed
fix the alwaysHasNoEffect predicate, and rename it to lastStatementHasNoEffect
1 parent 2e0244c commit db22916

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

javascript/ql/src/Statements/UseOfReturnlessFunction.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ predicate alwaysThrows(Function f) {
8585
/**
8686
* Holds if the last statement in the function is flagged by the js/useless-expression query.
8787
*/
88-
predicate alwaysHasNoEffect(Function f) {
89-
exists(ReachableBasicBlock entry, DataFlow::Node noEffect |
90-
entry = f.getEntryBB() and
91-
hasNoEffect(noEffect.asExpr()) and
92-
entry.dominates(noEffect.getBasicBlock())
88+
predicate lastStatementHasNoEffect(Function f) {
89+
exists(DataFlow::Node noEffect |
90+
noEffect.getContainer() = f and
91+
hasNoEffect(noEffect.asExpr()) and
92+
not exists(noEffect.getASuccessor())
9393
)
9494
}
9595

@@ -155,7 +155,7 @@ where
155155
name = "callback function"
156156
) and
157157
not benignContext(call.asExpr()) and
158-
not alwaysHasNoEffect(func) and
158+
not lastStatementHasNoEffect(func) and
159159
// anonymous one-shot closure. Those are used in weird ways and we ignore them.
160160
not oneshotClosure(call.asExpr())
161161
select

0 commit comments

Comments
 (0)