================
@@ -973,6 +1021,58 @@ class CommaVisitor : public
EvaluatedExprVisitor<CommaVisitor> {
};
}
+static void DiagnoseIfStmtRedundantDeferBody(Sema &S, SourceLocation IfLoc,
+ Stmt *thenStmt) {
----------------
Expertcoderz wrote:
You're right; I did notice it was incredibly hard to provide a consistent
fix-it in all cases (when there's multiple lines and indentation etc.), and it
may not really be worth the effort as you've pointed out.
> 1. Have `CheckRedundantDeferStmt()` return `true` if its argument is a
> `defer` statement.
>
> 2. In the `if` statement code, do `if (CheckRedundantDeferStmt()) { /* emit
> 'defer if' note*/ } `
>
> I’m not sure we need to care about the case where the if statement body is a
> compound statement with a single `defer` substatement.
This is now the case in 4ca5c1eb50ffb05f356572f0d268f20160c6e7c4. I've kept the
'defer if' note while removing both the fix-it hint and compound statement
detection so there's no need for a massive helper function.
https://github.com/llvm/llvm-project/pull/225748
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits