[PATCH] D23265: [clang-tidy] enhance readability-else-after-return

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 8 08:25:18 PDT 2016

alexfh requested changes to this revision.
This revision now requires changes to proceed.

Comment at: clang-tidy/readability/ElseAfterReturnCheck.cpp:38-40
@@ -34,2 +37,5 @@
   SourceLocation ElseLoc = If->getElseLoc();
-  DiagnosticBuilder Diag = diag(ElseLoc, "don't use else after return");
+  StringRef DiagMessage = "do not use 'else' or 'else if' after something that "
+                          "interrupts control flow - like return, break, "
+                          "throw, continue, goto, etc";
+  DiagnosticBuilder Diag = diag(ElseLoc, DiagMessage);
aaron.ballman wrote:
> I think it might be better to specifically identify the flow control construct used instead of a laundry list of possibilities. Then it can be "do not use '%select{else|else if}0' after '%1'".
The wording is actually good. For documentation (currently, http://clang.llvm.org/extra/clang-tidy/checks/readability-else-after-return.html is not extremely verbose ;)).

Otherwise, I agree with Aaron: the warning should be precise to avoid confusion.

Also, no need for a separate variable to keep the message, IMO.


More information about the cfe-commits mailing list