[PATCH] clang-tidy: Add initial check for "Don't use else after return".

David Blaikie dblaikie at gmail.com
Mon Jan 12 09:22:44 PST 2015

Not your problem, but I'm wondering: If/when/how we'll be able to integrate clang-tidy checks into the compile step for developers. This warning and many others in clang-tidy ought to be cheap enough to run at compile time and as hard errors just like many real clang warnings (the only reason they're not is that they're stylistic in nature and so don't meet that bar for the compiler warnings - not because they aren't cheap, low false positive, etc). It'd be nice not to have these as asynchronous results but as errors during the build.

Comment at: clang-tidy/misc/ElseAfterReturnCheck.cpp:38
@@ +37,3 @@
+  // FIXME: Removing the braces isn't always safe. Do a more careful analysis.
+  if (const CompoundStmt *CS = Result.Nodes.getNodeAs<CompoundStmt>("else"))
Is this the "quite a bit to do" you are referring to? Or are there other holes you know need fixing? (perhaps some could be included in the test case to give an idea of why this isn't ready for prime-time yet)



More information about the cfe-commits mailing list