Le 09.09.2016 12:38, Joe Perches a écrit :
On Fri, 2016-09-09 at 12:28 +0800, Julia Lawall wrote:
Le 09.09.2016 10:56, Joe Perches a écrit :
> Could coccinelle identify non-const arrays that are never modified
> by anything and add const like this patch below by some mechanism?
If you know the type that should be const, then Coccinlle can add the
consts everywhere.
Sure, but the fundamental here is that you don't know that
the type _could_ be const.
Coccinelle doesn't always have complete type information, because it
doesn't necessarily have access to all header files, so it is not
clear
that it could be useful for it to blindly search for all structures
that
are used in a read-only way.
In the example given the struct definitions are file local.
It's not an easy problem but it could be worthwhile when all
structure members are never modified after initialization.
If the structure type is file-local, it could indeed be possible to do
something. Thanks for the suggestion.
julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci