Size-type inconsistency (signedness) causes confusion and even bugs.
For example when signed compared to unsigned the result might not
be expected.
Summary of this commit:
Related APIs changes:
- getDynamicExtent() returns signed version of extent;
- Add getDynamicElementCountWithOffset() for offset version of element count;
- getElementExtent() could be 0, add defensive checking for getDynamicElementCount, if element is of zero-length, try ConstantArrayType::getSize() as element count;
Related checker changes:
- ArrayBoundCheckerV2: add testcase for signed <-> unsigned comparison from type-inconsistency results by getDynamicExtent()
- ExprInspection: use more general API to report more results
I think it's a good convention if getDynamicExtent() will always return concrete values as ArrayIndexTy. (If I didn't miss some very obscure case, then this will be true when this commit is merged.)