From 6bea23ff425c08ce924b1062c23d6bafcf775478 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 5 May 2025 14:19:43 +0100 Subject: [PATCH 1/3] Zend/zend_ast: Add const qualifier --- Zend/zend_ast.c | 86 ++++++++++++++++++++++----------------------- Zend/zend_ast.h | 20 +++++------ Zend/zend_compile.h | 2 +- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 9a028d736d1b2..facb4ef3accdd 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -33,7 +33,7 @@ static inline void *zend_ast_alloc(size_t size) { return zend_arena_alloc(&CG(ast_arena), size); } -static inline void *zend_ast_realloc(void *old, size_t old_size, size_t new_size) { +static inline void *zend_ast_realloc(const void *old, size_t old_size, size_t new_size) { void *new = zend_ast_alloc(new_size); memcpy(new, old, old_size); return new; @@ -43,7 +43,7 @@ static inline size_t zend_ast_list_size(uint32_t children) { return sizeof(zend_ast_list) - sizeof(zend_ast *) + sizeof(zend_ast *) * children; } -ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(znode *node) { +ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(const znode *node) { zend_ast_znode *ast; ast = zend_ast_alloc(sizeof(zend_ast_znode)); @@ -66,7 +66,7 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_fcc(void) { return (zend_ast *) ast; } -static zend_always_inline zend_ast * zend_ast_create_zval_int(zval *zv, uint32_t attr, uint32_t lineno) { +static zend_always_inline zend_ast * zend_ast_create_zval_int(const zval *zv, uint32_t attr, uint32_t lineno) { zend_ast_zval *ast; ast = zend_ast_alloc(sizeof(zend_ast_zval)); @@ -77,15 +77,15 @@ static zend_always_inline zend_ast * zend_ast_create_zval_int(zval *zv, uint32_t return (zend_ast *) ast; } -ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno(zval *zv, uint32_t lineno) { +ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno(const zval *zv, uint32_t lineno) { return zend_ast_create_zval_int(zv, 0, lineno); } -ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr) { +ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(const zval *zv, zend_ast_attr attr) { return zend_ast_create_zval_int(zv, attr, CG(zend_lineno)); } -ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(zval *zv) { +ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(const zval *zv) { return zend_ast_create_zval_int(zv, 0, CG(zend_lineno)); } @@ -508,7 +508,7 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *ast, zend_ast *op) return (zend_ast *) list; } -static zend_result zend_ast_add_array_element(zval *result, zval *offset, zval *expr) +static zend_result zend_ast_add_array_element(const zval *result, zval *offset, zval *expr) { if (Z_TYPE_P(offset) == IS_UNDEF) { if (!zend_hash_next_index_insert(Z_ARRVAL_P(result), expr)) { @@ -528,9 +528,9 @@ static zend_result zend_ast_add_array_element(zval *result, zval *offset, zval * return SUCCESS; } -static zend_result zend_ast_add_unpacked_element(zval *result, zval *expr) { +static zend_result zend_ast_add_unpacked_element(const zval *result, const zval *expr) { if (EXPECTED(Z_TYPE_P(expr) == IS_ARRAY)) { - HashTable *ht = Z_ARRVAL_P(expr); + const HashTable *ht = Z_ARRVAL_P(expr); zval *val; zend_string *key; @@ -1243,7 +1243,7 @@ static size_t ZEND_FASTCALL zend_ast_tree_size(zend_ast *ast) size = sizeof(zend_ast_fcc); } else if (zend_ast_is_list(ast)) { uint32_t i; - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); size = zend_ast_list_size(list->children); for (i = 0; i < list->children; i++) { @@ -1284,7 +1284,7 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf) Z_LINENO(new->val) = zend_ast_get_lineno(ast); buf = (void*)((char*)buf + sizeof(zend_ast_zval)); } else if (zend_ast_is_list(ast)) { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); zend_ast_list *new = (zend_ast_list*)buf; uint32_t i; new->kind = list->kind; @@ -1301,7 +1301,7 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf) } } } else if (ast->kind == ZEND_AST_OP_ARRAY) { - zend_ast_op_array *old = zend_ast_get_op_array(ast); + const zend_ast_op_array *old = zend_ast_get_op_array(ast); zend_ast_op_array *new = (zend_ast_op_array*)buf; new->kind = old->kind; new->attr = old->attr; @@ -1310,7 +1310,7 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf) function_add_ref((zend_function *)new->op_array); buf = (void*)((char*)buf + sizeof(zend_ast_op_array)); } else if (ast->kind == ZEND_AST_CALLABLE_CONVERT) { - zend_ast_fcc *old = (zend_ast_fcc*)ast; + const zend_ast_fcc *old = (zend_ast_fcc*)ast; zend_ast_fcc *new = (zend_ast_fcc*)buf; new->kind = old->kind; new->attr = old->attr; @@ -1371,7 +1371,7 @@ ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast) } else if (EXPECTED(ast->kind == ZEND_AST_ZVAL)) { zval_ptr_dtor_nogc(zend_ast_get_zval(ast)); } else if (EXPECTED(zend_ast_is_list(ast))) { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); if (list->children) { uint32_t i; @@ -1386,7 +1386,7 @@ ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast) } else if (EXPECTED(ast->kind == ZEND_AST_OP_ARRAY)) { destroy_op_array(zend_ast_get_op_array(ast)->op_array); } else if (EXPECTED(zend_ast_is_decl(ast))) { - zend_ast_decl *decl = (zend_ast_decl *) ast; + const zend_ast_decl *decl = (const zend_ast_decl *) ast; if (decl->name) { zend_string_release_ex(decl->name, 0); @@ -1465,7 +1465,7 @@ ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn, void *contex static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int priority, int indent); -static ZEND_COLD void zend_ast_export_str(smart_str *str, zend_string *s) +static ZEND_COLD void zend_ast_export_str(smart_str *str, const zend_string *s) { size_t i; @@ -1480,7 +1480,7 @@ static ZEND_COLD void zend_ast_export_str(smart_str *str, zend_string *s) } } -static ZEND_COLD void zend_ast_export_qstr(smart_str *str, char quote, zend_string *s) +static ZEND_COLD void zend_ast_export_qstr(smart_str *str, char quote, const zend_string *s) { size_t i; @@ -1536,7 +1536,7 @@ static ZEND_COLD void zend_ast_export_indent(smart_str *str, int indent) static ZEND_COLD void zend_ast_export_name(smart_str *str, zend_ast *ast, int priority, int indent) { if (ast->kind == ZEND_AST_ZVAL) { - zval *zv = zend_ast_get_zval(ast); + const zval *zv = zend_ast_get_zval(ast); if (Z_TYPE_P(zv) == IS_STRING) { smart_str_append(str, Z_STR_P(zv)); @@ -1549,7 +1549,7 @@ static ZEND_COLD void zend_ast_export_name(smart_str *str, zend_ast *ast, int pr static ZEND_COLD void zend_ast_export_ns_name(smart_str *str, zend_ast *ast, int priority, int indent) { if (ast->kind == ZEND_AST_ZVAL) { - zval *zv = zend_ast_get_zval(ast); + const zval *zv = zend_ast_get_zval(ast); if (Z_TYPE_P(zv) == IS_STRING) { if (ast->attr == ZEND_NAME_FQ) { @@ -1628,7 +1628,7 @@ static ZEND_COLD void zend_ast_export_var(smart_str *str, zend_ast *ast, int pri /* Use zend_ast_export_list() unless fewer than `list->children` children should * be exported. */ -static ZEND_COLD void zend_ast_export_list_ex(smart_str *str, zend_ast_list *list, bool separator, int priority, int indent, int children) +static ZEND_COLD void zend_ast_export_list_ex(smart_str *str, const zend_ast_list *list, bool separator, int priority, int indent, int children) { ZEND_ASSERT(children <= list->children); uint32_t i = 0; @@ -1642,12 +1642,12 @@ static ZEND_COLD void zend_ast_export_list_ex(smart_str *str, zend_ast_list *lis } } -static ZEND_COLD void zend_ast_export_list(smart_str *str, zend_ast_list *list, bool separator, int priority, int indent) +static ZEND_COLD void zend_ast_export_list(smart_str *str, const zend_ast_list *list, bool separator, int priority, int indent) { zend_ast_export_list_ex(str, list, separator, priority, indent, list->children); } -static ZEND_COLD void zend_ast_export_encaps_list(smart_str *str, char quote, zend_ast_list *list, int indent) +static ZEND_COLD void zend_ast_export_encaps_list(smart_str *str, char quote, const zend_ast_list *list, int indent) { uint32_t i = 0; zend_ast *ast; @@ -1655,7 +1655,7 @@ static ZEND_COLD void zend_ast_export_encaps_list(smart_str *str, char quote, ze while (i < list->children) { ast = list->child[i]; if (ast->kind == ZEND_AST_ZVAL) { - zval *zv = zend_ast_get_zval(ast); + const zval *zv = zend_ast_get_zval(ast); ZEND_ASSERT(Z_TYPE_P(zv) == IS_STRING); zend_ast_export_qstr(str, quote, Z_STR_P(zv)); @@ -1676,7 +1676,7 @@ static ZEND_COLD void zend_ast_export_encaps_list(smart_str *str, char quote, ze } } -static ZEND_COLD void zend_ast_export_name_list_ex(smart_str *str, zend_ast_list *list, int indent, const char *separator) +static ZEND_COLD void zend_ast_export_name_list_ex(smart_str *str, const zend_ast_list *list, int indent, const char *separator) { uint32_t i = 0; @@ -1692,7 +1692,7 @@ static ZEND_COLD void zend_ast_export_name_list_ex(smart_str *str, zend_ast_list #define zend_ast_export_name_list(s, l, i) zend_ast_export_name_list_ex(s, l, i, ", ") #define zend_ast_export_catch_name_list(s, l, i) zend_ast_export_name_list_ex(s, l, i, "|") -static ZEND_COLD void zend_ast_export_var_list(smart_str *str, zend_ast_list *list, int indent) +static ZEND_COLD void zend_ast_export_var_list(smart_str *str, const zend_ast_list *list, int indent) { uint32_t i = 0; @@ -1717,7 +1717,7 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in if (ast->kind == ZEND_AST_STMT_LIST || ast->kind == ZEND_AST_TRAIT_ADAPTATIONS) { - zend_ast_list *list = (zend_ast_list*)ast; + const zend_ast_list *list = (const zend_ast_list*)ast; uint32_t i = 0; while (i < list->children) { @@ -1744,8 +1744,8 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in case ZEND_AST_DECLARE: break; case ZEND_AST_PROP_GROUP: { - zend_ast *first_prop = zend_ast_get_list(ast->child[1])->child[0]; - zend_ast *hook_list = first_prop->child[3]; + const zend_ast *first_prop = zend_ast_get_list(ast->child[1])->child[0]; + const zend_ast *hook_list = first_prop->child[3]; if (hook_list == NULL) { smart_str_appendc(str, ';'); } @@ -1759,7 +1759,7 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in } } -static ZEND_COLD void zend_ast_export_if_stmt(smart_str *str, zend_ast_list *list, int indent) +static ZEND_COLD void zend_ast_export_if_stmt(smart_str *str, const zend_ast_list *list, int indent) { uint32_t i; zend_ast *ast; @@ -1783,7 +1783,7 @@ static ZEND_COLD void zend_ast_export_if_stmt(smart_str *str, zend_ast_list *lis zend_ast_export_indent(str, indent); smart_str_appends(str, "} else "); if (ast->child[1] && ast->child[1]->kind == ZEND_AST_IF) { - list = (zend_ast_list*)ast->child[1]; + list = (const zend_ast_list*)ast->child[1]; goto tail_call; } else { smart_str_appends(str, "{\n"); @@ -1796,7 +1796,7 @@ static ZEND_COLD void zend_ast_export_if_stmt(smart_str *str, zend_ast_list *lis smart_str_appendc(str, '}'); } -static ZEND_COLD void zend_ast_export_zval(smart_str *str, zval *zv, int priority, int indent) +static ZEND_COLD void zend_ast_export_zval(smart_str *str, const zval *zv, int priority, int indent) { ZVAL_DEREF(zv); switch (Z_TYPE_P(zv)) { @@ -1853,7 +1853,7 @@ static ZEND_COLD void zend_ast_export_zval(smart_str *str, zval *zv, int priorit } } -static ZEND_COLD void zend_ast_export_class_no_header(smart_str *str, zend_ast_decl *decl, int indent) { +static ZEND_COLD void zend_ast_export_class_no_header(smart_str *str, const zend_ast_decl *decl, int indent) { if (decl->child[0]) { smart_str_appends(str, " extends "); zend_ast_export_ns_name(str, decl->child[0], 0, indent); @@ -1869,9 +1869,9 @@ static ZEND_COLD void zend_ast_export_class_no_header(smart_str *str, zend_ast_d } static ZEND_COLD void zend_ast_export_attribute_group(smart_str *str, zend_ast *ast, int indent) { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); for (uint32_t i = 0; i < list->children; i++) { - zend_ast *attr = list->child[i]; + const zend_ast *attr = list->child[i]; if (i) { smart_str_appends(str, ", "); @@ -1887,7 +1887,7 @@ static ZEND_COLD void zend_ast_export_attribute_group(smart_str *str, zend_ast * } static ZEND_COLD void zend_ast_export_attributes(smart_str *str, zend_ast *ast, int indent, bool newlines) { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); uint32_t i; for (i = 0; i < list->children; i++) { @@ -1926,7 +1926,7 @@ static ZEND_COLD void zend_ast_export_visibility(smart_str *str, uint32_t flags, static ZEND_COLD void zend_ast_export_type(smart_str *str, zend_ast *ast, int indent) { if (ast->kind == ZEND_AST_TYPE_UNION) { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); for (uint32_t i = 0; i < list->children; i++) { if (i != 0) { smart_str_appendc(str, '|'); @@ -1936,7 +1936,7 @@ static ZEND_COLD void zend_ast_export_type(smart_str *str, zend_ast *ast, int in return; } if (ast->kind == ZEND_AST_TYPE_INTERSECTION) { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); for (uint32_t i = 0; i < list->children; i++) { if (i != 0) { smart_str_appendc(str, '&'); @@ -1951,7 +1951,7 @@ static ZEND_COLD void zend_ast_export_type(smart_str *str, zend_ast *ast, int in zend_ast_export_ns_name(str, ast, 0, indent); } -static ZEND_COLD void zend_ast_export_hook_list(smart_str *str, zend_ast_list *hook_list, int indent) +static ZEND_COLD void zend_ast_export_hook_list(smart_str *str, const zend_ast_list *hook_list, int indent) { smart_str_appends(str, " {"); smart_str_appendc(str, '\n'); @@ -1959,7 +1959,7 @@ static ZEND_COLD void zend_ast_export_hook_list(smart_str *str, zend_ast_list *h zend_ast_export_indent(str, indent); for (uint32_t i = 0; i < hook_list->children; i++) { - zend_ast_decl *hook = (zend_ast_decl *)hook_list->child[i]; + const zend_ast_decl *hook = (const zend_ast_decl *)hook_list->child[i]; zend_ast_export_visibility(str, hook->flags, ZEND_MODIFIER_TARGET_PROPERTY); if (hook->flags & ZEND_ACC_FINAL) { smart_str_appends(str, "final "); @@ -2033,7 +2033,7 @@ static ZEND_COLD void zend_ast_export_hook_list(smart_str *str, zend_ast_list *h static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int priority, int indent) { - zend_ast_decl *decl; + const zend_ast_decl *decl; int p, pl, pr; const char *op; @@ -2069,7 +2069,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio case ZEND_AST_CLOSURE: case ZEND_AST_ARROW_FUNC: case ZEND_AST_METHOD: - decl = (zend_ast_decl *) ast; + decl = (const zend_ast_decl *) ast; if (decl->child[4]) { bool newlines = !(ast->kind == ZEND_AST_CLOSURE || ast->kind == ZEND_AST_ARROW_FUNC); zend_ast_export_attributes(str, decl->child[4], indent, newlines); @@ -2128,7 +2128,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio } break; case ZEND_AST_CLASS: - decl = (zend_ast_decl *) ast; + decl = (const zend_ast_decl *) ast; if (decl->child[3]) { zend_ast_export_attributes(str, decl->child[3], indent, 1); } @@ -2523,7 +2523,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio case ZEND_AST_NEW: smart_str_appends(str, "new "); if (ast->child[0]->kind == ZEND_AST_CLASS) { - zend_ast_decl *decl = (zend_ast_decl *) ast->child[0]; + const zend_ast_decl *decl = (const zend_ast_decl *) ast->child[0]; if (decl->child[3]) { zend_ast_export_attributes(str, decl->child[3], indent, 0); } diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h index 08400cff5dd8e..2e561f225917a 100644 --- a/Zend/zend_ast.h +++ b/Zend/zend_ast.h @@ -239,9 +239,9 @@ typedef struct _zend_ast_fcc { typedef void (*zend_ast_process_t)(zend_ast *ast); extern ZEND_API zend_ast_process_t zend_ast_process; -ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno(zval *zv, uint32_t lineno); -ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr); -ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(zval *zv); +ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno(const zval *zv, uint32_t lineno); +ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(const zval *zv, zend_ast_attr attr); +ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(const zval *zv); ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_str(zend_string *str); ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_long(zend_long lval); @@ -348,15 +348,15 @@ static zend_always_inline size_t zend_ast_size(uint32_t children) { return XtOffsetOf(zend_ast, child) + (sizeof(zend_ast *) * children); } -static zend_always_inline bool zend_ast_is_special(zend_ast *ast) { +static zend_always_inline bool zend_ast_is_special(const zend_ast *ast) { return (ast->kind >> ZEND_AST_SPECIAL_SHIFT) & 1; } -static zend_always_inline bool zend_ast_is_decl(zend_ast *ast) { +static zend_always_inline bool zend_ast_is_decl(const zend_ast *ast) { return zend_ast_is_special(ast) && ast->kind >= ZEND_AST_FUNC_DECL; } -static zend_always_inline bool zend_ast_is_list(zend_ast *ast) { +static zend_always_inline bool zend_ast_is_list(const zend_ast *ast) { return (ast->kind >> ZEND_AST_IS_LIST_SHIFT) & 1; } static zend_always_inline zend_ast_list *zend_ast_get_list(zend_ast *ast) { @@ -369,7 +369,7 @@ static zend_always_inline zval *zend_ast_get_zval(zend_ast *ast) { return &((zend_ast_zval *) ast)->val; } static zend_always_inline zend_string *zend_ast_get_str(zend_ast *ast) { - zval *zv = zend_ast_get_zval(ast); + const zval *zv = zend_ast_get_zval(ast); ZEND_ASSERT(Z_TYPE_P(zv) == IS_STRING); return Z_STR_P(zv); } @@ -385,7 +385,7 @@ static zend_always_inline zend_string *zend_ast_get_constant_name(zend_ast *ast) return Z_STR(((zend_ast_zval *) ast)->val); } -static zend_always_inline uint32_t zend_ast_get_num_children(zend_ast *ast) { +static zend_always_inline uint32_t zend_ast_get_num_children(const zend_ast *ast) { ZEND_ASSERT(!zend_ast_is_list(ast)); ZEND_ASSERT(!zend_ast_is_special(ast)); @@ -393,10 +393,10 @@ static zend_always_inline uint32_t zend_ast_get_num_children(zend_ast *ast) { } static zend_always_inline uint32_t zend_ast_get_lineno(zend_ast *ast) { if (ast->kind == ZEND_AST_ZVAL) { - zval *zv = zend_ast_get_zval(ast); + const zval *zv = zend_ast_get_zval(ast); return Z_LINENO_P(zv); } else if (ast->kind == ZEND_AST_CONSTANT) { - zval *zv = &((zend_ast_zval *) ast)->val; + const zval *zv = &((const zend_ast_zval *) ast)->val; return Z_LINENO_P(zv); } else { return ast->lineno; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 39a159236f035..a083babcd8109 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -97,7 +97,7 @@ typedef struct _zend_ast_znode { znode node; } zend_ast_znode; -ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(znode *node); +ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(const znode *node); static zend_always_inline znode *zend_ast_get_znode(zend_ast *ast) { return &((zend_ast_znode *) ast)->node; From 34656693202f4bbb3479803ea584c5de798265b7 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 5 May 2025 14:46:22 +0100 Subject: [PATCH 2/3] Zend/zend_ast: Use zend_ast_get_list() instead of cast --- Zend/zend_ast.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index facb4ef3accdd..25a3676c9f7fc 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -2164,16 +2164,16 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio case ZEND_AST_EXPR_LIST: case ZEND_AST_PARAM_LIST: simple_list: - zend_ast_export_list(str, (zend_ast_list*)ast, 1, 20, indent); + zend_ast_export_list(str, zend_ast_get_list(ast), 1, 20, indent); break; case ZEND_AST_ARRAY: smart_str_appendc(str, '['); - zend_ast_export_list(str, (zend_ast_list*)ast, 1, 20, indent); + zend_ast_export_list(str, zend_ast_get_list(ast), 1, 20, indent); smart_str_appendc(str, ']'); break; case ZEND_AST_ENCAPS_LIST: smart_str_appendc(str, '"'); - zend_ast_export_encaps_list(str, '"', (zend_ast_list*)ast, indent); + zend_ast_export_encaps_list(str, '"', zend_ast_get_list(ast), indent); smart_str_appendc(str, '"'); break; case ZEND_AST_STMT_LIST: @@ -2181,16 +2181,16 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio zend_ast_export_stmt(str, ast, indent); break; case ZEND_AST_IF: - zend_ast_export_if_stmt(str, (zend_ast_list*)ast, indent); + zend_ast_export_if_stmt(str, zend_ast_get_list(ast), indent); break; case ZEND_AST_SWITCH_LIST: case ZEND_AST_CATCH_LIST: case ZEND_AST_MATCH_ARM_LIST: - zend_ast_export_list(str, (zend_ast_list*)ast, 0, 0, indent); + zend_ast_export_list(str, zend_ast_get_list(ast), 0, 0, indent); break; case ZEND_AST_CLOSURE_USES: smart_str_appends(str, " use("); - zend_ast_export_var_list(str, (zend_ast_list*)ast, indent); + zend_ast_export_var_list(str, zend_ast_get_list(ast), indent); smart_str_appendc(str, ')'); break; case ZEND_AST_PROP_GROUP: { @@ -2255,7 +2255,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio goto simple_list; case ZEND_AST_NAME_LIST: - zend_ast_export_name_list(str, (zend_ast_list*)ast, indent); + zend_ast_export_name_list(str, zend_ast_get_list(ast), indent); break; case ZEND_AST_USE: smart_str_appends(str, "use "); @@ -2329,7 +2329,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio case ZEND_AST_SHELL_EXEC: smart_str_appendc(str, '`'); if (ast->child[0]->kind == ZEND_AST_ENCAPS_LIST) { - zend_ast_export_encaps_list(str, '`', (zend_ast_list*)ast->child[0], indent); + zend_ast_export_encaps_list(str, '`', zend_ast_get_list(ast->child[0]), indent); } else { zval *zv; ZEND_ASSERT(ast->child[0]->kind == ZEND_AST_ZVAL); @@ -2626,7 +2626,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio case ZEND_AST_MATCH_ARM: zend_ast_export_indent(str, indent); if (ast->child[0]) { - zend_ast_export_list(str, (zend_ast_list*)ast->child[0], 1, 0, indent); + zend_ast_export_list(str, zend_ast_get_list(ast->child[0]), 1, 0, indent); smart_str_appends(str, " => "); } else { smart_str_appends(str, "default => "); @@ -2637,7 +2637,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio case ZEND_AST_DECLARE: smart_str_appends(str, "declare("); ZEND_ASSERT(ast->child[0]->kind == ZEND_AST_CONST_DECL); - zend_ast_export_list(str, (zend_ast_list*)ast->child[0], 1, 0, indent); + zend_ast_export_list(str, zend_ast_get_list(ast->child[0]), 1, 0, indent); smart_str_appendc(str, ')'); if (ast->child[1]) { smart_str_appends(str, " {\n"); From 89aa048558ff7ddf09eccb138c4aefba250ce702 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 5 May 2025 14:20:28 +0100 Subject: [PATCH 3/3] Zend/zend_ast: Use uint32_t type instead of int type --- Zend/zend_ast.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 25a3676c9f7fc..8d2c0077efa40 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -1628,7 +1628,7 @@ static ZEND_COLD void zend_ast_export_var(smart_str *str, zend_ast *ast, int pri /* Use zend_ast_export_list() unless fewer than `list->children` children should * be exported. */ -static ZEND_COLD void zend_ast_export_list_ex(smart_str *str, const zend_ast_list *list, bool separator, int priority, int indent, int children) +static ZEND_COLD void zend_ast_export_list_ex(smart_str *str, const zend_ast_list *list, bool separator, int priority, int indent, uint32_t children) { ZEND_ASSERT(children <= list->children); uint32_t i = 0;