Open Quuxplusone opened 9 years ago
Please provide a couple of examples of what specific patterns you want to address with an explanation of why this matters. If there are any style guides that have this rule, please add a pointer to them.
Hi, Alexander!
Even such trivial situations like:
return (true);
return (d_ClassMember);
Ideally it's great it will be replaced with:
return true;
return d_ClassMember;
Eugene.
It looks like a matter of readability only. Implementing this check is a good task for someone who wants to start contributing to clang-tidy ;)
(In reply to comment #1)
> Please provide a couple of examples of what specific patterns you want to
> address with an explanation of why this matters. If there are any style
> guides that have this rule, please add a pointer to them.
Google Style guide: http://google-
styleguide.googlecode.com/svn/trunk/cppguide.html#Return_Values
Direct link to specific section in google style guide:
https://google.github.io/styleguide/cppguide.html#Return_Values
FYI, since it came up in my review of redundant return statements, I started making a check for this. I think I just need to check if dyn_cast
return(expr);
and not
return expr;
However, I haven't verified this yet.
Ah, I hav a diff for that: http://reviews.llvm.org/D16286
I used a similar matcher there.
Hi!
I think will be good idea to have checks for style of returns in non-void functions as part of readability checkers.
Round brackets should be used only for expressions, not around variable/member.
Eugene.