This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] misc-braces-around-statements: add option ShortStatementLines to trigger this check only if the statement spans over at least a given number of lines.
ClosedPublic

Authored by curdeius on Oct 7 2014, 1:46 AM.

Details

Reviewers
alexfh

Diff Detail

Event Timeline

curdeius updated this revision to Diff 14491.Oct 7 2014, 1:46 AM
curdeius retitled this revision from to [clang-tidy] misc-braces-around-statements: add option ShortStatementLines to trigger this check only if the statement spans over at least a given number of lines..
curdeius updated this object.
curdeius edited the test plan for this revision. (Show Details)
curdeius added a reviewer: alexfh.
curdeius added a subscriber: curdeius.
curdeius added a subscriber: Unknown Object (MLST).Oct 7 2014, 1:47 AM
alexfh edited edge metadata.Oct 9 2014, 4:58 AM

The code is fine. I'm slightly concerned about the code duplication in the tests, but I see no better way of doing this. If we come up with something more elegant, we can always change this. Please address the comments and I'll commit the patch for you.

clang-tidy/misc/BracesAroundStatementsCheck.cpp
117

I'd change the default to 0U in order to use get<unsigned>.

test/clang-tidy/misc-braces-around-statements-always.cpp
6

You should be able to use the "-config" command line option added in r218511 to avoid creating a separate .clang-tidy file.

15

You can omit this, it's added implicitly by the script.

curdeius updated this revision to Diff 14671.Oct 9 2014, 12:52 PM
curdeius edited edge metadata.

Use -config to pass CheckOptions.

  • [clang-tidy] [misc-braces-around-statements] Using -config for tests instead of a new .clang-tidy file. Default value set to: 0U.
  • Merge branch 'master' into feature/misc-braces-around-statements-option
alexfh accepted this revision.Oct 13 2014, 5:58 AM
alexfh edited edge metadata.
This revision is now accepted and ready to land.Oct 13 2014, 5:58 AM
alexfh closed this revision.Oct 13 2014, 5:59 AM

Committed as r219611 with minor modifications:

merged test/clang-tidy/misc-braces-around-statements-always.cpp into
test/clang-tidy/misc-braces-around-statements.cpp and removed unnecessary
CHECK-NOTs from the tests.

Thanks for the patch!