On Wed, 2 Feb 2011, SF Markus Elfring wrote:
> > \(foo\|xxx\|yyy\)(...) {
> > <...
> > - alpha()
> > + beta()
> > ...>
> > }
> >
> > It works only on the functions foo, xxx, and bar, and does whatever is
> > specified in the <... ...>. For further efficiency, you could use <+...
> > ...+> That requires there to be at least one of what is inside, and thus
> > only functions where something useful can be done will be considered.
>
> You are right of course that this pattern finds also a specific detail in
> function implementations.
>
> I try to explain my previous feature request a bit more.
>
> Would you like to move this specification for a scope limitation into the SmPL
> meta-variable declaration area (your "@@ block")?
No.
> Can your source code transformation tool perform any optimisations to improve
> the analysis speed because of the knowledge that patterns should only be
> tested
> with the limited scope of function bodies?
It already has this knowledge if you put the function structure as in my
example and it already optimizes based on this information.
> I make some assumptions here about how your tool works.
> 1. The analysed source file is converted from a raw input of a character
> stream
> over an abstract syntax tree to an abstract semantic graph, isn't it?
>
> 2. Does the internal software infrastructure build a dedicated data structure
> like an index about all function declarations and/or definitions?
> If the answer to this question would be "No", I imagine that my previous
> suggestion would be useful because the additional indexing process will only
> be
> needed if the source code is really filtered in a function body.
You can use glimpse or id-utils to create an index in advance. Creating
an index every time one runs Coccinelle would be too slow. If there is no
index information, then Coccinelle uses grep before parsing a file. Once
it has parsed a file, it also makes an effort to figure out what code
fragments have to appear in a function for it to be relevant to the
semantic patch. Only those functions are processed in detail.
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)