Currently, a default index type in CSA is 'int'. However, this assumption seems to be incorrect for 64-bit platforms where index may be 64-bit as well as the array size. For example, it leads to unexpected overflows while performing pointer arithmetics. Moreover, PointerDiffType and 'int' cannot be used as a common array index type because arrays may have size (and indexes) more than PTRDIFF_MAX but less than SIZE_MAX. Since maximum array size for 64 bits is SIZE_MAX/8, I propose to use 'long long' as a common index type, although it looks a bit hacky for 32 bit.
How is this array index type used? Should it support negative values? If the answer is no, ASTContext has a getSizeType method. 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?
This type is used to make all the symbolic values for indices to have the same integer type (in SValBuilder).
They should support negative values because we are allowed to use negative index expressions.
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.
LongLongTy is initialized as a built-in type in ASTContext and, as I understand, is always available. It is not 64-bit on some platforms (like TCE), but these platforms don't have a wider type too.