On Fri, Jul 15, 2011 at 9:47 AM, Julia Lawall <[email protected]> wrote:
> On Fri, 15 Jul 2011, Andrea Canciani wrote:
>
>> I'm having some trouble writing a semantic patch which looks for accesses
>> to a field in a structure and replaces it with function calls.
>>
>> The structure type is a typedef type, as in the mini_nok.c attachment.
>> The debug.log shows the result of
>> "spatch -sp cocci.spatches/cairo_test_status.cocci mini_nok.c -debug"
>>
>> I suspect that the issue is in spatch because of the
>> "(ONCE) Missing type information. Certainly a pb in annotate_typer.ml"
>> message and because commenting out the first typedef and uncommenting
>> the second one fixes the problem.
>>
>> Nevertheless, I'm a noob to semantic patches and I could very well be wrong,
>> so any hint towards the solution of the problem would be appreciated.
>
> Yes, you have figured out the problem correctly.  You can see it by
> running spatch -type_c mini_nok.c with the typedef in the two places.
> Coccinelle seems to take the information about the type that is available
> at the time of the typedef, not at the time of the use of the typedef.  It
> should be possible to fix this.  In the meantime, if you do not have many
> structures with fields of type cairo_font_face_t * maybe you can just make
> specific rules for each of them, to run before the rule for
> cairo_font_face_t *?

I did this and it works (although it obviously makes the semantic patches
somewhat uglier).

I also tried to have a look at the c type annoter, but I didn't have much
success in finding out where the problem lies.
Unfortunately I'm no ocaml expert, so I would need some directions
to work on coccinelle.

If somebody is already working on fixing this issue, I'm available for
testing (although the code and patch I sent should already provide
a reasonable test case).

(The first Coccinelle-generated commit has already gone upstream
and I'm currently working on heavy code refactoring, which would
be near to impossible without such a useful tool, so I'm more than
willing to spend the time I'm saving thanks to it in improving it :) )

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

Reply via email to