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

Kirill Bobyrev via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 9 10:38:29 PDT 2016


omtcyfz added inline comments.

================
Comment at: clang-tidy/readability/ElseAfterReturnCheck.cpp:45
@@ +44,3 @@
+  for (const auto &BindingName :
+       {"return", "continue", "break", "goto", "throw"}) {
+    if (Result.Nodes.getNodeAs<Stmt>(BindingName)) {
----------------
alexfh wrote:
> This won't work in MSVC2013, I think. Just add a `const char *Labels[] = {"return", ...` (add more consts, constexprs or statics, if you like ;)
Hm, I'm confused. What exactly wouldn't work in MSVC?

================
Comment at: test/clang-tidy/readability-else-after-return.cpp:33
@@ -32,1 +32,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use 'else' after 'return'
+  // CHECK-FIXES: // comment
     f(0);
----------------
alexfh wrote:
> CHECK-FIXES pattern should be sticter. Current pattern will match for any `// comment` occurrence anywhere in the test file, even if it's on a different line and still prefixed with `else`.
> 
> Two action items here: 1. make comments and patterns unique, 2. anchor patterns to the start of line (`{{ˆ}}`).
Why make comments and patterns unique? If I anchor patterns to the start of line, it will only look at the line above, why does it need to be unique then?


https://reviews.llvm.org/D23265





More information about the cfe-commits mailing list