[PATCH] D134590: [clang-tidy] Fix a false positive in readability-simplify-boolean-expr
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 24 10:29:42 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8c783b8ec78e: [clang-tidy] Fix a false positive in readability-simplify-boolean-expr (authored by njames93).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134590/new/
https://reviews.llvm.org/D134590
Files:
clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/readability/simplify-bool-expr-chained-conditional-return.cpp
Index: clang-tools-extra/test/clang-tidy/checkers/readability/simplify-bool-expr-chained-conditional-return.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/readability/simplify-bool-expr-chained-conditional-return.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/simplify-bool-expr-chained-conditional-return.cpp
@@ -92,3 +92,14 @@
// CHECK-FIXES: {{^}} }{{$}}
// CHECK-FIXES: {{^ return i <= 10;$}}
// CHECK-FIXES: {{^}$}}
+
+
+bool PR57819(int x) {
+ // False positive introduced in clang-tidy-15
+ // Expect no warning here.
+ if (x > 0)
+ return false;
+ else {
+ }
+ return true;
+}
Index: clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -472,8 +472,8 @@
checkSingleStatement(If->getThen(), parseReturnLiteralBool);
if (ThenReturnBool &&
ThenReturnBool.Bool != TrailingReturnBool.Bool) {
- if (Check->ChainedConditionalReturn ||
- (!PrevIf && If->getElse() == nullptr)) {
+ if ((Check->ChainedConditionalReturn || !PrevIf) &&
+ If->getElse() == nullptr) {
Check->replaceCompoundReturnWithCondition(
Context, cast<ReturnStmt>(*Second), TrailingReturnBool.Bool,
If, ThenReturnBool.Item);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134590.462682.patch
Type: text/x-patch
Size: 1577 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220924/69ef2881/attachment.bin>
More information about the cfe-commits
mailing list