[PATCH] D46944: [analyzer] Use sufficiently large types for index/size calculation.

Aleksei Sidorin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 25 07:37:29 PDT 2018

a.sidorin added inline comments.

Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h:89
         SymMgr(context, BasicVals, alloc), MemMgr(context, alloc),
-        StateMgr(stateMgr), ArrayIndexTy(context.LongLongTy),
+        StateMgr(stateMgr), ArrayIndexTy(context.getSignedSizeType()),
         ArrayIndexWidth(context.getTypeSize(ArrayIndexTy)) {}
ebevhan wrote:
> a.sidorin wrote:
> > As you correctly pointed, ssize_t is 32-bit on 32-bit systems. Therefore, it is too short. So, we can leave this line as-is.
> But if it's hardcoded to LongLongTy, you have the same problem on 64-bit systems.
Some reasons why LongLongTy is used here are listed in D16063. In brief, you just cannot create an array of size greater than SIZE_MAX/2  on 64-bit platforms.


More information about the cfe-commits mailing list