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