[clang] [analyzer] Fix handling of zero-sized elements in ArrayBound (PR #218712)
DonĂ¡t Nagy via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 26 03:53:13 PDT 2026
================
@@ -200,6 +200,14 @@ static bool isDeterminedByInterestingSymbol(SVal SV,
return false;
}
+static int64_t getElementSize(const ElementRegion *ER, SValBuilder &SVB) {
+ QualType ElemType = ER->getElementType();
+
+ assert(!ElemType->isIncompleteType() && "ElemType cannot be incomplete");
----------------
NagyDonat wrote:
I'm pretty sure that the element type of an `ElementRegion` can never be an incomplete type. In particular, the `ArrayBound` checker activates for subscript expressions, pointer dereference and the arrow operator, and neither of these compiles when the element type is incomplete.
One or two years ago investigated this and came to the conclusion that the `if` was superfluous, but left it in place because I didn't see an immediate need. Now I replaced the `if` with an assert because I had to refactor the code and keeping an `if` would have been uncomfortable.
https://github.com/llvm/llvm-project/pull/218712
More information about the cfe-commits
mailing list