Skip to content

Commit a72bc0c

Browse files
committed
Include empty statements in allowlist
1 parent 31b8064 commit a72bc0c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ predicate isAllowedReturnValue(Expr retval) {
8787
* Matches if `s` is an allowed unreachable statement.
8888
*/
8989
predicate allowlist(Stmt s) {
90+
s instanceof EmptyStmt
91+
or
9092
// `panic("unreachable")` and similar
9193
exists(CallExpr ce | ce = s.(ExprStmt).getExpr() or ce = s.(ReturnStmt).getExpr() |
9294
ce.getTarget().mustPanic() or ce.getCalleeName().toLowerCase() = "error"
@@ -100,7 +102,7 @@ predicate allowlist(Stmt s) {
100102

101103
/** Holds if `s` is part of a non-reportable prefix of a run of unreachable statements. */
102104
predicate isInNonReportableUnreachablePrefix(Stmt s) {
103-
(allowlist(s) or s instanceof EmptyStmt) and
105+
allowlist(s) and
104106
(
105107
firstUnreachableStmt(s)
106108
or
@@ -111,7 +113,6 @@ predicate isInNonReportableUnreachablePrefix(Stmt s) {
111113
/** Holds if `s` is the first non-allowlisted statement in a run of unreachable statements. */
112114
predicate firstNonAllowlistedUnreachableStmt(Stmt s) {
113115
not isReachable(s) and
114-
not s instanceof EmptyStmt and
115116
not allowlist(s) and
116117
(
117118
firstUnreachableStmt(s)

0 commit comments

Comments
 (0)