[clang-tools-extra] [clang-tidy] Improve redundant-casting check for binary operation (PR #191386)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 14 08:37:08 PDT 2026


================
@@ -168,6 +171,33 @@ void testFunctionalCastWithInitExpr(unsigned a) {
   unsigned c = unsigned{0};
 }
 
+void testBinaryOperatorRedundantCasting() {
+  const auto diff_types_operands1 { static_cast<float>(1.0f + 1) };
----------------
vbvictor wrote:

As for options, there are some for this check (like IgnoreTypeAliases).
So all you need is to add new option (look at how others are made) and pass it to `anyBinaryOperatorOperandsTypesEqualToOperatorResultType`.

Option name could be `IgnoreImplicitTypePromotion` (I just asked AI), will be false by default. If user make it `true` - they can get previous behavoir.

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


More information about the cfe-commits mailing list