[clang-tools-extra] [clang-tidy] Correcting fix suggestion in `readability-simplify-boolean-expr` (PR #178392)

Björn Svensson via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 3 07:23:27 PST 2026


================
@@ -162,7 +162,8 @@ static std::string replacementExpression(const ASTContext &Context,
   if (const auto *EC = dyn_cast<ExprWithCleanups>(E))
     E = EC->getSubExpr();
 
-  const bool NeedsStaticCast = needsStaticCast(E);
+  const bool NeedsStaticCast =
+      Context.getLangOpts().CPlusPlus && needsStaticCast(E);
----------------
bjosv wrote:

The output from the fixer for C23 gets very similar to the output for C++ when skipping the cast.
I also ran this version on the added testcode to check for any warnings in the fixer-result, and it seems to work fine without C-casts in [godbolt](https://godbolt.org/z/dM3n1dEEs) as well. 



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


More information about the cfe-commits mailing list