ptr-arith.c revision d7d5f0223bd30dfd618762349c6209dd1d5ea3e6
1// RUN: clang-cc -analyze -checker-simple -analyzer-store=region -verify %s &&
2// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s &&
3// RUN: clang-cc -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