[clang] [Clang][Sema] Add -Wredundant-defer to diagnose redundant `_Defer`s (PR #225748)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 24 03:14:37 PDT 2026
================
@@ -997,6 +1014,14 @@ StmtResult Sema::ActOnIfStmt(SourceLocation IfLoc,
if (!ConstevalOrNegatedConsteval && !elseStmt)
DiagnoseEmptyStmtBody(RParenLoc, thenStmt, diag::warn_empty_if_body);
+ if (isa<DeferStmt>(thenStmt))
+ Diag(thenStmt->getBeginLoc(), diag::warn_redundant_defer)
+ << thenStmt->getSourceRange();
+
+ if (elseStmt && isa<DeferStmt>(elseStmt))
+ Diag(elseStmt->getBeginLoc(), diag::warn_redundant_defer)
+ << elseStmt->getSourceRange();
+
----------------
Expertcoderz wrote:
@Sirraide I've opened the NFC as #226101.
https://github.com/llvm/llvm-project/pull/225748
More information about the cfe-commits
mailing list