summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-few-lines.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/readability-braces-around-statements-few-lines.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/readability-braces-around-statements-few-lines.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-few-lines.cpp b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-few-lines.cpp
new file mode 100644
index 00000000000..d4a878104e9
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-few-lines.cpp
@@ -0,0 +1,31 @@
+// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 4}]}" --
+// REQUIRES: shell
+
+void do_something(const char *) {}
+
+bool cond(const char *) {
+ return false;
+}
+
+void test() {
+ if (cond("if1") /*comment*/) do_something("same-line");
+
+ if (cond("if2"))
+ do_something("single-line");
+
+ if (cond("if3") /*comment*/)
+ // some comment
+ do_something("three"
+ "lines");
+
+ if (cond("if4") /*comment*/)
+ // some comment
+ do_something("many"
+ "many"
+ "many"
+ "many"
+ "lines");
+ // CHECK-MESSAGES: :[[@LINE-7]]:31: warning: statement should be inside braces
+ // CHECK-FIXES: if (cond("if4") /*comment*/) {
+ // CHECK-FIXES: }
+}
OpenPOWER on IntegriCloud