[PATCH] D16063: [Analyzer] Use a wider integer type for an array index

Aleksei Sidorin via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 11 07:42:36 PST 2016


a.sidorin added a comment.

In http://reviews.llvm.org/D16063#323462, @xazax.hun wrote:

> How is this array index type used?


This type is used to make all the symbolic values for indices to have the same integer type (in SValBuilder).

In http://reviews.llvm.org/D16063#323462, @xazax.hun wrote:

> Should it support negative values? If the answer is no, ASTContext has a getSizeType method.


They should support negative values because we are allowed to use negative index expressions.

In http://reviews.llvm.org/D16063#323462, @xazax.hun wrote:

> If it is yes, it also has a getPointerDiffType method (although it returns a QualType not a CanQualType). Is there a reason not to use them?


As I described before, PtrDiffType is signed and is limited to SIZE_MAX/2. However, we are allowed to create arrays with the size more than SIZE_MAX/2 (see testIndexTooBig() test for details). But we should not loose the ability to handle such arrays and their indices.That's why I selected a 64-bit arch-independent type.


Repository:
  rL LLVM

http://reviews.llvm.org/D16063





More information about the cfe-commits mailing list