As per the LLVM coding standards:
http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return
Initial version, probably still quite a bit to do until this is really useful.
Differential D6927
clang-tidy: Add initial check for "Don't use else after return". djasper on Jan 12 2015, 9:01 AM. Authored by
Details
As per the LLVM coding standards: Initial version, probably still quite a bit to do until this is really useful.
Diff Detail Event TimelineComment Actions 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 Actions Maybe there's scope for a way to add warnings/errors which are run as a separate AST consumer, rather than integrated into the parsing/lexing code path. That way, you don't pay for them if you don't use them (also you don't pay for them in added complexity within the parsing/lexing code). I think most AST-based clang-tidy checks would fit that model. We also have a warning we added internally that would be very nice to cleanly segregate out of the main code path like that. Comment Actions The rule applies to other control statements as well, such as break, continue and throw (may be also goto, but who cares about this rule when a goto is used?). Can we handle them in the same check? Then the name may need to be changed.
Comment Actions It does apply to other statements and we are going to implement those in this check, but I'd like the check to have the same name as the rule in the coding standard. Also, after "return" seems to be by far the most frequent case.
|
Please add a FIXME to support continue, break and throw.