[PATCH] D16286: [clang-tidy] Readability check for redundant parenthesis in return expression.
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 25 07:30:23 PST 2016
aaron.ballman added a comment.
In http://reviews.llvm.org/D16286#333911, @LegalizeAdulthood wrote:
> As a general comment, I am continually fascinated by the **huge** variety of opinion as to matters of readability within the C++ community. I don't know why we have so many differing opinions compared to the communities built around other programming languages, but I enjoy hearing all of them. I enjoy having my opinions on readability challenged because it forces me to think **why** I find one form preferable over another and that is a good thing.
Likewise! I think these discussions have been great (and I apologize if they are a source of frustration while we wrestle with the details).
> In http://reviews.llvm.org/D16286#330390, @aaron.ballman wrote:
> > In http://reviews.llvm.org/D16286#330360, @LegalizeAdulthood wrote:
> > > One could argue that this check should be part of the google module. The google style guide specifically forbids writing return with extra parenthesis.
> > If it is meant to work for a particular style guide, then it should absolutely go under that style guide. But for something more generally under the readability-* umbrella, I think it doesn't hurt to discuss where to draw the line, or what options may be valuable.
> I think that is the correct conclusion here; according to the bug report this check is motivated by the Google style guide which explicitly prohibits the parens for return expressions.
Then perhaps this should go under google-* instead of readability-*? However, I posed an idea in a different review about a more general solution to the problem that may make sense under readability-* with specific options for an alias under google-*. Perhaps it would make sense to make this a general "strip *all* parens that don't have an effect on the order of evaluation in all expressions" check, which leaves room for an additional (different) check in the future that says "put parens in anywhere based on this heuristic we can debate in the future". I would say that these two checks should be off-by-default since they will definitely conflict, but I think the alias under google-* should be on by default and only focus on return statements (or whatever else the google style guide requires).
(Not saying that you have to implement this -- I'm just exploring the design space. The initial implementation of this idea could simply be to take your existing check and put it under google-* and we can refactor some day in the future for a more generalized readability-* check.)
More information about the cfe-commits