File: call-summaries-pr107072.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (91 lines) | stat: -rw-r--r-- 2,621 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* { dg-require-effective-target int32plus } */
/* { dg-additional-options "-fanalyzer-call-summaries --param analyzer-min-snodes-for-call-summary=0 -Wno-analyzer-symbol-too-complex" } */

/* There need to be at least two calls to a function for the
   call-summarization code to be used.
   TODO: add some kind of test that summarization *was* used.  */

/* Reduced from an example in Emacs in which string_char_and_length
   was being incorrectly summarized, failing to see the write to *length.  */

typedef long int ptrdiff_t;
typedef struct Lisp_X *Lisp_Word;
typedef Lisp_Word Lisp_Object;
extern _Bool STRING_MULTIBYTE(Lisp_Object str);
extern unsigned char *SDATA(Lisp_Object string);
enum { MAX_2_BYTE_CHAR = 0x7FF };
enum { MAX_3_BYTE_CHAR = 0xFFFF };
enum { MAX_4_BYTE_CHAR = 0x1FFFFF };
enum { MAX_5_BYTE_CHAR = 0x3FFF7F };
extern int make_char_multibyte(int c);
static inline int string_char_and_length(unsigned char const *p, int *length) {
  int c = p[0];
  if (!(c & 0x80)) {
    *length = 1;
    return c;
  }
  ((0xC0 <= c) ? (void)0 : __builtin_unreachable());
  int d = (c << 6) + p[1] - ((0xC0 << 6) + 0x80);
  if (!(c & 0x20)) {
    *length = 2;
    return d + (c < 0xC2 ? 0x3FFF80 : 0);
  }
  d = (d << 6) + p[2] - ((0x20 << 12) + 0x80);
  if (!(c & 0x10)) {
    *length = 3;
    ((MAX_2_BYTE_CHAR < d && d <= MAX_3_BYTE_CHAR)
     ? (void)0
     : __builtin_unreachable());
    return d;
  }
  d = (d << 6) + p[3] - ((0x10 << 18) + 0x80);
  if (!(c & 0x08)) {
    *length = 4;
    ((MAX_3_BYTE_CHAR < d && d <= MAX_4_BYTE_CHAR)
     ? (void)0
     : __builtin_unreachable());
    return d;
  }
  d = (d << 6) + p[4] - ((0x08 << 24) + 0x80);
  *length = 5;
  ((MAX_4_BYTE_CHAR < d && d <= MAX_5_BYTE_CHAR)
   ? (void)0
   : __builtin_unreachable());
  return d;
}
int fetch_string_char_advance(Lisp_Object string,
			      ptrdiff_t *charidx,
			      ptrdiff_t *byteidx) {
  int output;
  ptrdiff_t b = *byteidx;
  unsigned char *chp = SDATA(string) + b;
  if (STRING_MULTIBYTE(string)) {
    int chlen;
    output = string_char_and_length(chp, &chlen);
    b += chlen;
  } else {
    output = *chp;
    b++;
  }
  (*charidx)++;
  *byteidx = b;
  return output;
}
int fetch_string_char_as_multibyte_advance(Lisp_Object string,
					   ptrdiff_t *charidx,
					   ptrdiff_t *byteidx) {
  int output;
  ptrdiff_t b = *byteidx;
  unsigned char *chp = SDATA(string) + b;
  if (STRING_MULTIBYTE(string)) {
    int chlen;
    output = string_char_and_length(chp, &chlen);
    b += chlen;
  } else {
    output = make_char_multibyte(*chp);
    b++;
  }
  (*charidx)++;
  *byteidx = b;
  return output;
}