| // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,alpha.security.ArrayBoundV2 -Wno-implicit-function-declaration -verify %s |
| // RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core,alpha.security.ArrayBoundV2 -Wno-implicit-function-declaration -DM32 -verify %s |
| // expected-no-diagnostics |
| #define X86_ARRAY_SIZE (UINT_MAX/2 + 4) |
| char arr[X86_ARRAY_SIZE]; |
| char *ptr = arr + UINT_MAX/2; |
| ptr += 2; // index shouldn't overflow |
| #define ARRAY_SIZE 0x100000000 |
| void testIndexOverflow64() { |
| char *ptr = arr + UINT_MAX/2; |
| ptr += 2; // don't overflow 64-bit index |
| #define BIG_INDEX (ULONG_MAX/16) |
| void testIndexTooBig64() { |
| char *ptr = arr + BIG_INDEX; |
| ptr += 2; // don't overflow 64-bit index |
| static unsigned buf[SIZE]; |
| buf[SIZE-1] = 1; // no-warning |
| void testOutOfBoundsCopy1() { |
| memcpy(buf, addr, size); // no-warning |
| void testOutOfBoundsCopy2() { |
| memcpy(addr, buf, size); // no-warning |