[PATCH] D16259: Add clang-tidy readability-redundant-control-flow check

Richard via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 3 16:56:41 PST 2016


In article <CAAt6xTtsVoLmF5B9=A7_TLJsO5qrA6O1vD-a=DbRUOMy0-CX4w at mail.gmail.com>,
    Aaron Ballman <aaron.ballman at gmail.com> writes:

> On Wed, Feb 3, 2016 at 3:57 PM, Kim Gräsman <kim.grasman at gmail.com> wrote:
> > On Mon, Feb 1, 2016 at 4:32 PM, Aaron Ballman <aaron.ballman at gmail.com>
> wrote:
> >>
> >> ================
> >> Comment at: clang-tidy/readability/RedundantControlFlowCheck.cpp:60
> >> @@ +59,3 @@
> >> +  if (const auto *Return = dyn_cast<ReturnStmt>(*last))
> >> +    issueDiagnostic(Result, Block, Return->getSourceRange(),
> >> +                    RedundantReturnDiag);
> >> ----------------
> >> It is the LLVM coding style (though I don't personally care for it), and
> you are right -- a clang-tidy check in the LLVM module wouldn't be amiss.
> :-)
> >
> > Isn't this:
> http://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-state
ments.html?
> 
> Yes, that seems to be it. Probably could have an alias in the LLVM
> umbrella that points here.

Sorry, I accidentally sent my first reply only to Kim Grasman.

No, google-readability-braces-around-statements doesn't apply LLVM coding
style rules.

google-readability-braces-around-statements tries to put braces around all
control structure bodies, but unfortunately creates errors.
<https://llvm.org/bugs/show_bug.cgi?id=26229>
<https://llvm.org/bugs/show_bug.cgi?id=26228>
<https://llvm.org/bugs/show_bug.cgi?id=26205>

It's a google-XXX check because that check is applying Google coding
style guidelines where braces are required around all control
structures.

LLVM uses a different coding style guideline for braces,
at least judging from code reviews I've had.  I just looked at
<http://llvm.org/docs/CodingStandards.html> and couldn't find any specific
mention of when braces are supposed to be used, I just keep getting dinged
in phabricator in what seems to me to be arbitrary ideas about when braces
should or shouldn't be used for single statement control structure bodies.

Instead of arbitrarily dinging code in reviews, I would prefer that
someone update the coding standards document to define what the rule
is and then we can write a clang-tidy checker that applies the rule.
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>


More information about the cfe-commits mailing list