[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:06:09 PDT 2018


a.sidorin added a comment.

This is a nice extension of https://reviews.llvm.org/D16063.



================
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());
 }
----------------
I think we should initialize SValBuilder::ArrayIndexTy with getSignedSizeType() instead of LongLongTy and use `svalBuilder.getArrayIndexType()` here instead.


================
Comment at: test/Analysis/array-index.c:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.security.ArrayBound,alpha.unix.cstring.OutOfBounds -verify -Wno-implicit-function-declaration %s
+
----------------
Can we place these tests into Analysis/index-type.c?


Repository:
  rC Clang

https://reviews.llvm.org/D46944





More information about the cfe-commits mailing list