[clang-tools-extra] [clang-tidy][NFC] Remove unnecessary nullptr check on cast subexpr (PR #85473)

via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 15 14:57:58 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: Mike Rice (mikerice1969)

<details>
<summary>Changes</summary>

The value of SubExpr is not null since getSubExpr would assert in that case. Remove the nullptr check. This avoids confusion since SubExpr is used without check later in the function.

---
Full diff: https://github.com/llvm/llvm-project/pull/85473.diff


1 Files Affected:

- (modified) clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp (+1-2) 


``````````diff
diff --git a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
index 4f02950e7794cb..74152c6034510b 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -81,8 +81,7 @@ void fixGenericExprCastToBool(DiagnosticBuilder &Diag,
 
   const Expr *SubExpr = Cast->getSubExpr();
 
-  bool NeedInnerParens =
-      SubExpr != nullptr && utils::fixit::areParensNeededForStatement(*SubExpr);
+  bool NeedInnerParens = utils::fixit::areParensNeededForStatement(*SubExpr);
   bool NeedOuterParens =
       Parent != nullptr && utils::fixit::areParensNeededForStatement(*Parent);
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/85473


More information about the cfe-commits mailing list