summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/readability-simplify-bool-expr.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2015-05-17 12:31:12 +0000
committerAlexander Kornienko <alexfh@google.com>2015-05-17 12:31:12 +0000
commitfb3e2cd8ccea054cae31d6576f5b98b97f15f6ac (patch)
treeed0124d819b826dd38b813316cf5d5bcde951534 /clang-tools-extra/test/clang-tidy/readability-simplify-bool-expr.cpp
parent53958e187a624142498f42d4a67a8e64b65b1c6c (diff)
downloadbcm5719-llvm-fb3e2cd8ccea054cae31d6576f5b98b97f15f6ac.tar.gz
bcm5719-llvm-fb3e2cd8ccea054cae31d6576f5b98b97f15f6ac.zip
[clang-tidy] Enhance clang-tidy readability-simplify-boolean-expr check...
Enhance clang-tidy readability-simplify-boolean-expr check to handle chained conditional assignment and chained conditional return. Based on feedback from applying this tool to the clang/LLVM codebase, this changeset improves the readability-simplify-boolean-expr check so that conditional assignment or return statements at the end of a chain of if/else if statements are left unchanged unless a configuration option is supplied. http://reviews.llvm.org/D8996 Patch by Richard Thomson! llvm-svn: 237541
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/readability-simplify-bool-expr.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/readability-simplify-bool-expr.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/readability-simplify-bool-expr.cpp b/clang-tools-extra/test/clang-tidy/readability-simplify-bool-expr.cpp
index 0658a17b278..708270fedf9 100644
--- a/clang-tools-extra/test/clang-tidy/readability-simplify-bool-expr.cpp
+++ b/clang-tools-extra/test/clang-tidy/readability-simplify-bool-expr.cpp
@@ -541,3 +541,55 @@ void complex_conditional_assignment_statements(int i) {
} else
f = false;
}
+
+// unchanged: chained return statements, but ChainedConditionalReturn not set
+bool chained_conditional_compound_return(int i) {
+ if (i < 0) {
+ return true;
+ } else if (i < 10) {
+ return false;
+ } else if (i > 20) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// unchanged: chained return statements, but ChainedConditionalReturn not set
+bool chained_conditional_return(int i) {
+ if (i < 0)
+ return true;
+ else if (i < 10)
+ return false;
+ else if (i > 20)
+ return true;
+ else
+ return false;
+}
+
+// unchanged: chained assignments, but ChainedConditionalAssignment not set
+void chained_conditional_compound_assignment(int i) {
+ bool b;
+ if (i < 0) {
+ b = true;
+ } else if (i < 10) {
+ b = false;
+ } else if (i > 20) {
+ b = true;
+ } else {
+ b = false;
+ }
+}
+
+// unchanged: chained return statements, but ChainedConditionalReturn not set
+void chained_conditional_assignment(int i) {
+ bool b;
+ if (i < 0)
+ b = true;
+ else if (i < 10)
+ b = false;
+ else if (i > 20)
+ b = true;
+ else
+ b = false;
+}
OpenPOWER on IntegriCloud