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

via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 16 03:14:49 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.h clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp
index 8cd943ceb..aba6b42a1 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp
@@ -75,8 +75,9 @@ static bool binaryOperatorOperandsTypesEqualToOperatorResultType(
     // IgnoreImplicitCasts = false: neither of operands type matches cast type
     // IgnoreImplicitCasts = true: at least one operand type doesn't match cast
     //                             type
-    const bool castIsNeeded = IgnoreImplicitCasts ? (!LHSMatches || !RHSMatches)
-                                                  : (!LHSMatches && !RHSMatches);
+    const bool castIsNeeded = IgnoreImplicitCasts
+                                  ? (!LHSMatches || !RHSMatches)
+                                  : (!LHSMatches && !RHSMatches);
     if (castIsNeeded)
       return false;
   }

``````````

</details>


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


More information about the cfe-commits mailing list