[PATCH] D46944: [analyzer] Use sufficiently large types for index/size calculation.
Aleksei Sidorin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 16 08:57:46 PDT 2018
a.sidorin added inline comments.
================
Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1344
// This is a signed value, since it's used in arithmetic with signed indices.
- return svalBuilder.makeIntVal(RegionSize / EleSize, false);
+ return svalBuilder.makeIntVal(RegionSize / EleSize, Ctx.getSignedSizeType());
}
----------------
ebevhan wrote:
> a.sidorin wrote:
> > I think we should initialize SValBuilder::ArrayIndexTy with getSignedSizeType() instead of LongLongTy and use `svalBuilder.getArrayIndexType()` here instead.
> I made the change, but it caused a spurious out of bounds warning in index-type.c for the 32-bit case. Making the type signed means that anything above MAX/2 will break, and the test uses arrays of that size.
Hm, yes. ssize_t is 32-bit on 32-bit targets but our indices can exceed it. Even if so, `svalBuilder.getArrayIndexType()` should be fine.
Repository:
rC Clang
https://reviews.llvm.org/D46944
More information about the cfe-commits
mailing list