Coverage Report

Created: 2022-07-08 09:39

/home/mdboom/Work/builds/cpython/Include/internal/pycore_asdl.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef Py_INTERNAL_ASDL_H
2
#define Py_INTERNAL_ASDL_H
3
#ifdef __cplusplus
4
extern "C" {
5
#endif
6
7
#ifndef Py_BUILD_CORE
8
#  error "this header requires Py_BUILD_CORE define"
9
#endif
10
11
#include "pycore_pyarena.h"       // _PyArena_Malloc()
12
13
typedef PyObject * identifier;
14
typedef PyObject * string;
15
typedef PyObject * object;
16
typedef PyObject * constant;
17
18
/* It would be nice if the code generated by asdl_c.py was completely
19
   independent of Python, but it is a goal the requires too much work
20
   at this stage.  So, for example, I'll represent identifiers as
21
   interned Python strings.
22
*/
23
24
#define _ASDL_SEQ_HEAD \
25
    Py_ssize_t size;   \
26
    void **elements;
27
28
typedef struct {
29
    _ASDL_SEQ_HEAD
30
} asdl_seq;
31
32
typedef struct {
33
    _ASDL_SEQ_HEAD
34
    void *typed_elements[1];
35
} asdl_generic_seq;
36
37
typedef struct {
38
    _ASDL_SEQ_HEAD
39
    PyObject *typed_elements[1];
40
} asdl_identifier_seq;
41
42
typedef struct {
43
    _ASDL_SEQ_HEAD
44
    int typed_elements[1];
45
} asdl_int_seq;
46
47
asdl_generic_seq *_Py_asdl_generic_seq_new(Py_ssize_t size, PyArena *arena);
48
asdl_identifier_seq *_Py_asdl_identifier_seq_new(Py_ssize_t size, PyArena *arena);
49
asdl_int_seq *_Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena);
50
51
52
#define GENERATE_ASDL_SEQ_CONSTRUCTOR(NAME, TYPE) \
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 0]
  Branch (58:9): [True: 0, False: 41.1k]
  Branch (58:9): [True: 0, False: 234k]
  Branch (58:9): [True: 0, False: 612]
  Branch (58:9): [True: 0, False: 1.48k]
  Branch (58:9): [True: 0, False: 0]
  Branch (58:9): [True: 0, False: 126k]
  Branch (58:9): [True: 0, False: 36.9k]
  Branch (58:9): [True: 0, False: 1.33k]
  Branch (58:9): [True: 0, False: 394]
  Branch (58:9): [True: 0, False: 29]
  Branch (58:9): [True: 0, False: 354]
  Branch (58:9): [True: 0, False: 597]
  Branch (58:9): [True: 0, False: 1.86M]
  Branch (58:9): [True: 0, False: 427]
  Branch (58:9): [True: 0, False: 30.0k]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))1.88M
)) { \
  Branch (59:10): [True: 0, False: 0]
  Branch (59:18): [True: 0, False: 0]
  Branch (59:10): [True: 28.8k, False: 12.2k]
  Branch (59:18): [True: 0, False: 28.8k]
  Branch (59:10): [True: 134k, False: 100k]
  Branch (59:18): [True: 0, False: 134k]
  Branch (59:10): [True: 608, False: 4]
  Branch (59:18): [True: 0, False: 608]
  Branch (59:10): [True: 1.32k, False: 158]
  Branch (59:18): [True: 0, False: 1.32k]
  Branch (59:10): [True: 0, False: 0]
  Branch (59:18): [True: 0, False: 0]
  Branch (59:10): [True: 12.0k, False: 114k]
  Branch (59:18): [True: 0, False: 12.0k]
  Branch (59:10): [True: 7.78k, False: 29.1k]
  Branch (59:18): [True: 0, False: 7.78k]
  Branch (59:10): [True: 1.33k, False: 2]
  Branch (59:18): [True: 0, False: 1.33k]
  Branch (59:10): [True: 393, False: 1]
  Branch (59:18): [True: 0, False: 393]
  Branch (59:10): [True: 29, False: 0]
  Branch (59:18): [True: 0, False: 29]
  Branch (59:10): [True: 339, False: 15]
  Branch (59:18): [True: 0, False: 339]
  Branch (59:10): [True: 29, False: 568]
  Branch (59:18): [True: 0, False: 29]
  Branch (59:10): [True: 1.66M, False: 198k]
  Branch (59:18): [True: 0, False: 1.66M]
  Branch (59:10): [True: 416, False: 11]
  Branch (59:18): [True: 0, False: 416]
  Branch (59:10): [True: 30.0k, False: 0]
  Branch (59:18): [True: 0, False: 30.0k]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))1.88M
:
0455k
); \
  Branch (63:10): [True: 0, False: 0]
  Branch (63:10): [True: 28.8k, False: 12.2k]
  Branch (63:10): [True: 134k, False: 100k]
  Branch (63:10): [True: 608, False: 4]
  Branch (63:10): [True: 1.32k, False: 158]
  Branch (63:10): [True: 0, False: 0]
  Branch (63:10): [True: 12.0k, False: 114k]
  Branch (63:10): [True: 7.78k, False: 29.1k]
  Branch (63:10): [True: 1.33k, False: 2]
  Branch (63:10): [True: 393, False: 1]
  Branch (63:10): [True: 29, False: 0]
  Branch (63:10): [True: 339, False: 15]
  Branch (63:10): [True: 29, False: 568]
  Branch (63:10): [True: 1.66M, False: 198k]
  Branch (63:10): [True: 416, False: 11]
  Branch (63:10): [True: 30.0k, False: 0]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 0]
  Branch (65:9): [True: 0, False: 41.1k]
  Branch (65:9): [True: 0, False: 234k]
  Branch (65:9): [True: 0, False: 612]
  Branch (65:9): [True: 0, False: 1.48k]
  Branch (65:9): [True: 0, False: 0]
  Branch (65:9): [True: 0, False: 126k]
  Branch (65:9): [True: 0, False: 36.9k]
  Branch (65:9): [True: 0, False: 1.33k]
  Branch (65:9): [True: 0, False: 394]
  Branch (65:9): [True: 0, False: 29]
  Branch (65:9): [True: 0, False: 354]
  Branch (65:9): [True: 0, False: 597]
  Branch (65:9): [True: 0, False: 1.86M]
  Branch (65:9): [True: 0, False: 427]
  Branch (65:9): [True: 0, False: 30.0k]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 0]
  Branch (71:9): [True: 0, False: 41.1k]
  Branch (71:9): [True: 0, False: 234k]
  Branch (71:9): [True: 0, False: 612]
  Branch (71:9): [True: 0, False: 1.48k]
  Branch (71:9): [True: 0, False: 0]
  Branch (71:9): [True: 0, False: 126k]
  Branch (71:9): [True: 0, False: 36.9k]
  Branch (71:9): [True: 0, False: 1.33k]
  Branch (71:9): [True: 0, False: 394]
  Branch (71:9): [True: 0, False: 29]
  Branch (71:9): [True: 0, False: 354]
  Branch (71:9): [True: 0, False: 597]
  Branch (71:9): [True: 0, False: 1.86M]
  Branch (71:9): [True: 0, False: 427]
  Branch (71:9): [True: 0, False: 30.0k]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
Unexecuted instantiation: _Py_asdl_mod_seq_new
_Py_asdl_stmt_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 41.1k]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))28.8k
)) { \
  Branch (59:10): [True: 28.8k, False: 12.2k]
  Branch (59:18): [True: 0, False: 28.8k]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))28.8k
:
012.2k
); \
  Branch (63:10): [True: 28.8k, False: 12.2k]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 41.1k]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 41.1k]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
_Py_asdl_expr_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 234k]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))134k
)) { \
  Branch (59:10): [True: 134k, False: 100k]
  Branch (59:18): [True: 0, False: 134k]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))134k
:
0100k
); \
  Branch (63:10): [True: 134k, False: 100k]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 234k]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 234k]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
_Py_asdl_comprehension_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 612]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))608
)) { \
  Branch (59:10): [True: 608, False: 4]
  Branch (59:18): [True: 0, False: 608]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))608
:
04
); \
  Branch (63:10): [True: 608, False: 4]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 612]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 612]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
_Py_asdl_excepthandler_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 1.48k]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))1.32k
)) { \
  Branch (59:10): [True: 1.32k, False: 158]
  Branch (59:18): [True: 0, False: 1.32k]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))1.32k
:
0158
); \
  Branch (63:10): [True: 1.32k, False: 158]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 1.48k]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 1.48k]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
Unexecuted instantiation: _Py_asdl_arguments_seq_new
_Py_asdl_arg_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 126k]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))12.0k
)) { \
  Branch (59:10): [True: 12.0k, False: 114k]
  Branch (59:18): [True: 0, False: 12.0k]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))12.0k
:
0114k
); \
  Branch (63:10): [True: 12.0k, False: 114k]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 126k]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 126k]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
_Py_asdl_keyword_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 36.9k]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))7.78k
)) { \
  Branch (59:10): [True: 7.78k, False: 29.1k]
  Branch (59:18): [True: 0, False: 7.78k]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))7.78k
:
029.1k
); \
  Branch (63:10): [True: 7.78k, False: 29.1k]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 36.9k]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 36.9k]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
_Py_asdl_alias_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 1.33k]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))1.33k
)) { \
  Branch (59:10): [True: 1.33k, False: 2]
  Branch (59:18): [True: 0, False: 1.33k]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))1.33k
:
02
); \
  Branch (63:10): [True: 1.33k, False: 2]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 1.33k]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 1.33k]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
_Py_asdl_withitem_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 394]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))393
)) { \
  Branch (59:10): [True: 393, False: 1]
  Branch (59:18): [True: 0, False: 393]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))393
:
01
); \
  Branch (63:10): [True: 393, False: 1]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 394]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 394]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
_Py_asdl_match_case_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 29]
59
        (size && (((size_t)size - 1) > (SIZE_MAX / sizeof(void *))))) { \
  Branch (59:10): [True: 29, False: 0]
  Branch (59:18): [True: 0, False: 29]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? (sizeof(TYPE *) * (size - 1)) : 
00
); \
  Branch (63:10): [True: 29, False: 0]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 29]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 29]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
_Py_asdl_pattern_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 354]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))339
)) { \
  Branch (59:10): [True: 339, False: 15]
  Branch (59:18): [True: 0, False: 339]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))339
:
015
); \
  Branch (63:10): [True: 339, False: 15]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 354]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 354]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
_Py_asdl_type_ignore_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 597]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))29
)) { \
  Branch (59:10): [True: 29, False: 568]
  Branch (59:18): [True: 0, False: 29]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))29
:
0568
); \
  Branch (63:10): [True: 29, False: 568]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 597]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 597]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
_Py_asdl_generic_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 1.86M]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))1.66M
)) { \
  Branch (59:10): [True: 1.66M, False: 198k]
  Branch (59:18): [True: 0, False: 1.66M]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))1.66M
:
0198k
); \
  Branch (63:10): [True: 1.66M, False: 198k]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 1.86M]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 1.86M]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
_Py_asdl_identifier_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 427]
59
        (size && 
(((size_t)size - 1) > (SIZE_MAX / sizeof(void *)))416
)) { \
  Branch (59:10): [True: 416, False: 11]
  Branch (59:18): [True: 0, False: 416]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? 
(sizeof(TYPE *) * (size - 1))416
:
011
); \
  Branch (63:10): [True: 416, False: 11]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 427]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 427]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
_Py_asdl_int_seq_new
Line
Count
Source
53
asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) \
54
{ \
55
    asdl_ ## NAME ## _seq *seq = NULL; \
56
    size_t n; \
57
    /* check size is sane */ \
58
    if (size < 0 || \
  Branch (58:9): [True: 0, False: 30.0k]
59
        (size && (((size_t)size - 1) > (SIZE_MAX / sizeof(void *))))) { \
  Branch (59:10): [True: 30.0k, False: 0]
  Branch (59:18): [True: 0, False: 30.0k]
60
        PyErr_NoMemory(); \
61
        return NULL; \
62
    } \
63
    n = (size ? (sizeof(TYPE *) * (size - 1)) : 
00
); \
  Branch (63:10): [True: 30.0k, False: 0]
64
    /* check if size can be added safely */ \
65
    if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { \
  Branch (65:9): [True: 0, False: 30.0k]
66
        PyErr_NoMemory(); \
67
        return NULL; \
68
    } \
69
    n += sizeof(asdl_ ## NAME ## _seq); \
70
    seq = (asdl_ ## NAME ## _seq *)_PyArena_Malloc(arena, n); \
71
    if (!seq) { \
  Branch (71:9): [True: 0, False: 30.0k]
72
        PyErr_NoMemory(); \
73
        return NULL; \
74
    } \
75
    memset(seq, 0, n); \
76
    seq->size = size; \
77
    seq->elements = (void**)seq->typed_elements; \
78
    return seq; \
79
}
80
81
#define asdl_seq_GET_UNTYPED(S, I) _Py_RVALUE((S)->elements[(I)])
82
#define asdl_seq_GET(S, I) _Py_RVALUE((S)->typed_elements[(I)])
83
#define asdl_seq_LEN(S) _Py_RVALUE(((S) == NULL ? 0 : (S)->size))
84
85
#ifdef Py_DEBUG
86
#  define asdl_seq_SET(S, I, V) \
87
    do { \
88
        Py_ssize_t _asdl_i = (I); \
89
        assert((S) != NULL); \
90
        assert(0 <= _asdl_i && _asdl_i < (S)->size); \
91
        (S)->typed_elements[_asdl_i] = (V); \
92
    } while (0)
93
#else
94
#  define asdl_seq_SET(S, I, V) _Py_RVALUE((S)->typed_elements[(I)] = (V))
95
#endif
96
97
#ifdef Py_DEBUG
98
#  define asdl_seq_SET_UNTYPED(S, I, V) \
99
    do { \
100
        Py_ssize_t _asdl_i = (I); \
101
        assert((S) != NULL); \
102
        assert(0 <= _asdl_i && _asdl_i < (S)->size); \
103
        (S)->elements[_asdl_i] = (V); \
104
    } while (0)
105
#else
106
#  define asdl_seq_SET_UNTYPED(S, I, V) _Py_RVALUE((S)->elements[(I)] = (V))
107
#endif
108
109
#ifdef __cplusplus
110
}
111
#endif
112
#endif /* !Py_INTERNAL_ASDL_H */