diff options
author | Alexander Kornienko <alexfh@google.com> | 2015-12-28 13:21:22 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2015-12-28 13:21:22 +0000 |
commit | 4f74ec0dd8828aa80130a2c709239607f6316b8c (patch) | |
tree | 0bc25b1616cf6637fffd132bc11b41442c6fd943 /clang-tools-extra/test/clang-tidy/readability-simplify-bool-expr.cpp | |
parent | 9c10490efe30ed75d52810c26e83189a96c04926 (diff) | |
download | bcm5719-llvm-4f74ec0dd8828aa80130a2c709239607f6316b8c.tar.gz bcm5719-llvm-4f74ec0dd8828aa80130a2c709239607f6316b8c.zip |
[clang-tidy] Preserve comments and preprocessor directives when simplifying boolean expressions
This changeset still emits the diagnostic that the expression could be simplified, but it doesn't generate any fix-its that would lose comments or preprocessor directives within the text that would be replaced.
Fixes PR25842
Reviewers: alexfh
Subscribers: xazax.hun, cfe-commits
Patch by Richard Thomson! (+a naming style fix)
Differential Revision: http://reviews.llvm.org/D15737
llvm-svn: 256492
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.cpp | 24 |
1 files changed, 24 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 58cb416f37f..e3276103ded 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 @@ -871,3 +871,27 @@ bool negated_null_pointer_condition(int *p4) { } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return // CHECK-FIXES: return p4 != nullptr;{{$}} + +bool comments_in_the_middle(bool b) { + if (b) { + return true; + } else { + // something wicked this way comes + return false; + } +} +// CHECK-MESSAGES: :[[@LINE-6]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: {{^}} if (b) { +// CHECK-FIXES: // something wicked this way comes{{$}} + +bool preprocessor_in_the_middle(bool b) { + if (b) { + return true; + } else { +#define SOMETHING_WICKED false + return false; + } +} +// CHECK-MESSAGES: :[[@LINE-6]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: {{^}} if (b) { +// CHECK-FIXES: {{^}}#define SOMETHING_WICKED false |