[clang] [Sema] Don't assert when range checks see a float under an int cast (PR #233521)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 21 06:51:19 PDT 2026


================
@@ -12141,8 +12141,15 @@ static std::optional<IntRange> TryGetExprRange(ASTContext &C, const Expr *E,
 
   // Try a full evaluation first.
   Expr::EvalResult result;
-  if (E->EvaluateAsRValue(result, C, InConstantContext))
+  if (E->EvaluateAsRValue(result, C, InConstantContext)) {
+    // GetValueRange only handles integer-like values.
+    // Return nullopt for unsupported types.
+    if (!result.Val.isInt() && !result.Val.isVector() &&
----------------
AaronBallman wrote:

This predicate is going to be very hard to maintain as `APValue` changes over time. I think it'd be better to change `GetValueRange` to return an `optional<IntRange>` 

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


More information about the cfe-commits mailing list