[clang] [clang][Static analyzer] fix crash on using `bitcast(<type>, <array>)` as array subscript (PR #101647)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 2 03:23:12 PDT 2024


================
@@ -472,7 +472,19 @@ SVal StoreManager::getLValueElement(QualType elementType, NonLoc Offset,
   const auto *ElemR = dyn_cast<ElementRegion>(BaseRegion);
 
   // Convert the offset to the appropriate size and signedness.
-  Offset = svalBuilder.convertToArrayIndex(Offset).castAs<NonLoc>();
+  auto Off = svalBuilder.convertToArrayIndex(Offset).getAs<NonLoc>();
----------------
steakhal wrote:

```suggestion
  Offset = svalBuilder.convertToArrayIndex(Offset).getAs<NonLoc>().value_or(UnknownVal());
```

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


More information about the cfe-commits mailing list