From: Markus Elfring Date: Sat, 16 Nov 2019 16:33:26 GMT Subject: Re: coccinelle: adjustments for array.cocci? Message-ID: <05ab1110-2115-7886-f890-9983caabc52c@web.de> In-Reply-To: <5189f847-1af1-f050-6c72-576a977f6f12@web.de> > This reduces duplication in the semantic patch, which is nice. I think > I tried something like that at the time, but found that it failed to > produce some of the cases in 921d49be86 ("use COPY_ARRAY for copying > arrays", 2019-06-15) for some reason. I propose to integrate an other solution variant. * How do you think about to delete questionable transformation rules together with increasing the usage of nested disjunctions in this script for the semantic patch language? * Can a single transformation rule become sufficient for the discussed change pattern? @@ type T; T* dst_ptr, src_ptr, ptr; T[] dst_arr, src_arr; expression n, x; @@ ( -memcpy +COPY_ARRAY ( ( dst_ptr | dst_arr ) , ( src_ptr | src_arr ) - , (n) * \( sizeof(T) \| sizeof( \( *(x) \| x[...] \) ) \) + , n ) | -memmove +MOVE_ARRAY (dst_ptr, src_ptr - , (n) * \( sizeof(* \( dst_ptr \| src_ptr \) ) \| sizeof(T) \) + , n ) | -ptr = xmalloc((n) * \( sizeof(*ptr) \| sizeof(T) \)) +ALLOC_ARRAY(ptr, n) ) Would you like to clarify remaining challenges for pretty-printing in such use cases? Regards, Markus