Skip to content

Commit 51f654d

Browse files
committed
Make firstNonAllowlistedUnreachableStmt simpler
1 parent a72bc0c commit 51f654d

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

‎go/ql/src/RedundantCode/UnreachableStatement.ql‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,18 @@ predicate allowlist(Stmt s) {
100100
)
101101
}
102102

103-
/** Holds if `s` is part of a non-reportable prefix of a run of unreachable statements. */
104-
predicate isInNonReportableUnreachablePrefix(Stmt s) {
103+
Stmt firstNonAllowlisted(Stmt s) {
104+
not allowlist(s) and result = s
105+
or
105106
allowlist(s) and
106-
(
107-
firstUnreachableStmt(s)
108-
or
109-
isInNonReportableUnreachablePrefix(getPreviousStmt(s))
110-
)
107+
exists(Stmt next | getPreviousStmt(next) = s | result = firstNonAllowlisted(next))
111108
}
112109

113110
/** Holds if `s` is the first non-allowlisted statement in a run of unreachable statements. */
114111
predicate firstNonAllowlistedUnreachableStmt(Stmt s) {
115-
not isReachable(s) and
116-
not allowlist(s) and
117-
(
118-
firstUnreachableStmt(s)
119-
or
120-
isInNonReportableUnreachablePrefix(getPreviousStmt(s))
112+
exists(Stmt unreachable |
113+
firstUnreachableStmt(unreachable) and
114+
s = firstNonAllowlisted(unreachable)
121115
)
122116
}
123117

0 commit comments

Comments
 (0)