[Cocci] Wildcard matching
Julia Lawall
julia at diku.dk
Thu Apr 30 14:37:18 CEST 2009
On Thu, 30 Apr 2009, Derek M Jones wrote:
>
> Julia,
>
> > > Is there any way around this? I don't think it should be necessary to
> > > write *all* versions of these functions?
> >
> > Since there is no particular reason why a function whose name contains a
> > particular substring has a particular function, Coccinelle doesn't support
> > wildcards. Perhaps you can find some other distinguishing feature of the
> > function, such as its argument type (I guess not in this case) or the type
> > that it returns. Otherwise, you have to write them all out.
>
> There is lots of empirical evidence to suggest that developers do use
> particular substrings to denote related functionality.
>
> shape-of-code.coding-guidelines.com/2008/12/naming-used-to-predict-object-lifetime/
> www.knosof.co.uk/cbook/accu08.html
> and for more than you could possibly want to know about identifiers
> www.knosof.co.uk/cbook/cbook1_1.pdf
>
> Working on mining common sequences of operations
> http://www.cs.virginia.edu/perracotta
> provides more evidence that some sequences appear throughout source.
Sure. But some don't. In looking at Linux code, sometimes the same
prefix is used for more than one thing, and sometimes a few things in a
particular category do not contain the expected prefix. For automatic
transformation, it seems safer to rely on properties such as the structure
field in which a function is stored or the way in which the result of a
function is used.
julia
More information about the Cocci
mailing list