mesa/src/compiler/clc
Alyssa Rosenzweig b824ef83ab util/dynarray: infer type in append
Most of the time, we can infer the type to append in
util_dynarray_append using __typeof__, which is standardized in C23 and
support in Jesse's MSMSVCV. This patch drops the type argument most of
the time, making util_dynarray a little more ergonomic to use.

This is done in four steps.

First, rename util_dynarray_append -> util_dynarray_append_typed

    bash -c "find . -type f -exec sed -i -e 's/util_dynarray_append(/util_dynarray_append_typed(/g' \{} \;"

Then, add a new append that infers the type. This is much more ergonomic
for what you want most of the time.

Next, use type-inferred append as much as possible, via Coccinelle
patch (plus manual fixup):

    @@
    expression dynarray, element;
    type type;
    @@

    -util_dynarray_append_typed(dynarray, type, element);
    +util_dynarray_append(dynarray, element);

Finally, hand fixup cases that Coccinelle missed or incorrectly
translated, of which there were several because we can't used the
untyped append with a literal (since the sizeof won't do what you want).

All four steps are squashed to produce a single patch changing every
util_dynarray_append call site in tree to either drop a type parameter
(if possible) or insert a _typed suffix (if we can't infer). As such,
the final patch is best reviewed by hand even though it was
tool-assisted.

No Long Linguine Meals were involved in the making of this patch.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38038>
2025-10-24 18:32:07 +00:00
..
clc.c clc: Tell clang to track imported dependencies 2024-12-06 13:48:26 -05:00
clc.h clc: add support for cl_ext_image_unorm_int_2_101010 2025-06-30 18:04:59 +00:00
clc_helpers.cpp clc: Fix createDiagnostics for LLVM-22 2025-10-03 18:44:30 +00:00
clc_helpers.h rusticl/feat: LinkOnce ODR 2025-01-31 13:46:41 +00:00
mesa_clc.c util/dynarray: infer type in append 2025-10-24 18:32:07 +00:00
meson.build mesa-clc: add an option to force inclusion of OpenCL headers 2025-04-24 11:40:15 +00:00
nir_clc_helpers.h nir: move the libclc lowering over to functions file. 2023-09-12 01:57:50 +00:00
nir_load_libclc.c clc: force exact! across libclc 2025-08-01 21:00:47 +00:00