ptr-arith.c revision 610e81d6b7248ce4be4be2252b03a5d4052c9835
1// RUN: clang -analyze -checker-simple -analyzer-store=region -verify %s && 2// RUN: clang -analyze -checker-cfref -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s && 3// RUN: clang -analyze -checker-cfref -analyzer-store=region -verify -triple i686-apple-darwin9 %s 4 5void f1() { 6 int a[10]; 7 int *p = a; 8 ++p; 9} 10 11char* foo(); 12 13void f2() { 14 char *p = foo(); 15 ++p; 16} 17 18// This test case checks if we get the right rvalue type of a TypedViewRegion. 19// The ElementRegion's type depends on the array region's rvalue type. If it was 20// a pointer type, we would get a loc::SymbolVal for '*p'. 21char* memchr(); 22static int 23domain_port (const char *domain_b, const char *domain_e, 24 const char **domain_e_ptr) 25{ 26 int port = 0; 27 28 const char *p; 29 const char *colon = memchr (domain_b, ':', domain_e - domain_b); 30 31 for (p = colon + 1; p < domain_e ; p++) 32 port = 10 * port + (*p - '0'); 33 return port; 34} 35