[clang] [clang][StaticAnalyzer] Fix crash in SimpleSValBuilder with unsigned __int128 and negative literals (PR #150225)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 25 06:16:46 PDT 2025


================
@@ -149,6 +149,12 @@ BuiltinFunctionChecker::checkOverflow(CheckerContext &C, SVal RetVal,
   // Calling a builtin with a non-integer type result produces compiler error.
   assert(Res->isIntegerType());
 
+  // If RetVal is unknown or undefined, we can't determine overflow
+  if (RetVal.isUnknown() || RetVal.isUndef()) {
----------------
steakhal wrote:

```suggestion
  if (RetVal.isUnknownOrUndef()) {
```

My question here would be: If `RetVal` was unknown, then both `IsLeMax` and `IsGeMin` would become unknown, which in turn would eventually return `{true,true}` as I later elaborate from what I can tell reading this.

If `RetVal` was `Undef` then `IsLeMax` and `IsGeMin` would be also `Undef` and the `IsLeMax.castAs<DefinedOrUnknownSVal>()` cast would trigger an assert/crash.
Consequently, I'm not convinced that `RetVal` can be `Undef` here.

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


More information about the cfe-commits mailing list