[PATCH] [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.

Alexander Kornienko alexfh at google.com
Thu Oct 9 04:59:01 PDT 2014


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.

================
Comment at: clang-tidy/misc/BracesAroundStatementsCheck.cpp:117
@@ +116,3 @@
+      // Always add braces by default.
+      ShortStatementLines(Options.get("ShortStatementLines", 0)) {}
+
----------------
I'd change the default to 0U in order to use get<unsigned>.

================
Comment at: test/clang-tidy/misc-braces-around-statements-always.cpp:5
@@ +4,3 @@
+// RUN: echo '{ Checks: "-*,misc-braces-around-statements", CheckOptions: [{key: misc-braces-around-statements.ShortStatementLines, value: 0}]}' > %t/.clang-tidy
+// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-braces-around-statements %t/t.cpp
+
----------------
You should be able to use the "-config" command line option added in r218511 to avoid creating a separate .clang-tidy file.

================
Comment at: test/clang-tidy/misc-braces-around-statements-always.cpp:14
@@ +13,3 @@
+void test() {
+  // CHECK-NOT: warning
+
----------------
You can omit this, it's added implicitly by the script.

http://reviews.llvm.org/D5642






More information about the cfe-commits mailing list