[clang] [Clang] Fix assertion "unsigned range includes negative?" in AnalyzeComparison during Sema of vector comparison with mismatched signed/unsigned types and __builtin_convertvector (PR #182627)

Yutong Zhu via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 2 10:56:20 PST 2026


================
@@ -11679,6 +11500,15 @@ static std::optional<IntRange> TryGetExprRange(ASTContext &C, const Expr *E,
                                Approximate);
       }
 
+      QualType T = E->getType();
+      if (const auto *VT = T->getAs<VectorType>()) {
+        QualType ElemTy = VT->getElementType();
+        if (ElemTy->isUnsignedIntegerType()) {
+          return TryGetExprRange(C, UO->getSubExpr(), MaxWidth,
+                                 InConstantContext, Approximate);
+        }
+      }
+
----------------
YutongZhuu wrote:

Thanks for the suggestion. I implemented a small helper function in this file to deduplicate the type checking logic in this change. Let me know what do you like the current implementation.

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


More information about the cfe-commits mailing list