[clang] [Sema] Fix -Wunreachable-code false negative when operands differ only by implicit casts (PR #149972)

M. Zeeshan Siddiqui via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 29 12:07:10 PDT 2025


================
@@ -1160,8 +1160,11 @@ class CFGBuilder {
       return {};
 
     // Check that it is the same variable on both sides.
-    if (!Expr::isSameComparisonOperand(DeclExpr1, DeclExpr2))
-      return {};
+    if (!Expr::isSameComparisonOperand(DeclExpr1, DeclExpr2)) {
+      if (!Expr::isSameComparisonOperand(DeclExpr1->IgnoreParenImpCasts(),
+                                         DeclExpr2->IgnoreParenImpCasts()))
+        return {};
----------------
codemzs wrote:

Thanks, I have moved the check into `isSameComparisonOperand()`

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


More information about the cfe-commits mailing list