On Fri, 11 Mar 2011 08:06:37 +0100 (CET)
Julia Lawall <[email protected]> wrote:

> This is the only option that comes to mind.  The problem is that (to the 
> best of my knowledge) coccinelle only uses the definitions of macros if it 
> can't parse the code otherwise, and in your case it has no problem parsing 
> the code.  Perhaps there is a way to generate the isomorphisms 
> automatically?  You could do it using Coccinelle actually, since you can 
> match on #define I1 I2 and then write some python or ocaml code to print 
> out the isomorphism definition.

Indeed, generating isomorphisms should be easy. But another thing that I don't 
like is the need to
write 'using "caml.iso"' in every rule :(
Now I've got another idea - simply create the patch to convert all old names 
(alloc_small) to new 
ones (caml_alloc_small) and then apply other patches after this one using new 
names only. Looks like a win-win :)
 
> I don't think there is any need to use a regular expression here, since as 
> far as I can see you just want to match a set of fixed names.  In the 
> second argument to caml_alloc you can put:
> 
> \(No_scan_tag\|Abstract_tag\|String_tag\|Double_tag\|...\)
> 
> (where ... is the rest of your names, not the SmPL ...)
> 
> If you do this, the SmPL compiler has more information and can better 
> optimize your rule.

Yes, that was my first attempt and it scared me with warnings :

warning: line 7: should No_scan_tag be a metavariable?
warning: line 7: should Abstract_tag be a metavariable?
warning: line 7: should String_tag be a metavariable?
warning: line 7: should Double_tag be a metavariable?
warning: line 7: should Double_array_tag be a metavariable?
warning: line 7: should Custom_tag be a metavariable?

but as I rechecked now it seems to work. Nevertheless regexp is still needed
for the second case when I want to match everything _except_ this identifiers..
 
> local idexpression v means that v is restricted to be a local variable.  
> If you just want it to be a variable, but don't care about it being a 
> local one, you can drop the local.  If you don't even care about it being 
> a variable, eg you would like to allow a->b, then you can just put 
> expression.
> 
> Constant is for constants, such as 27.  But it also considers an 
> identifier that is all capital letters (possibly containing numbers) as a 
> constant as well, because the names gives to #define in Linux usually have 
> this form.
> 
> An identifier is the name of a structure field, a #define, a function, or 
> a variable.  Is is the name of something rather than an expression that 
> has a value.  But it is a bit confusing, because an identifier can be used 
> in the position of an expression as well.

Thanks for your answers!
(I guess the above paragraphs could be really helpful in the manual ;) )

-- 
 ygrek
 http://ygrek.org.ua/
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to