On Sun, 2015-02-15 at 10:56PM +0100, Julia Lawall wrote:
> On Sun, 15 Feb 2015, Sören Brinkmann wrote:
>
> > On Sun, 2015-02-15 at 10:41PM +0100, Julia Lawall wrote:
> > > > If you look at my example, I tested by creating types.h (in the same
> > > > directory), that did include the single line 'typedef unsigned int u32;'
> > > > only. I then ran
> > > > spatch --all-includes -I . --sp-file test.cocci testcase2.c
> > > > But that doesn't seem to make any difference. If I move the typedef into
> > > > the c file, it works though.
> > >
> > > OK, maybe types in header files are indeed treated differently.
> >
> > I even tried --preprocess without seeing different behavior. No clue
> > what's going on there.
>
> No idea... I can try to check.
>
> > > A patch that adds a few more parsing hacks is below. It may apply to
> > > your version or you may need to upgrade.
> >
> > Applied and rebuilt. That seems to do the trick. My testcase passes and
> > even on the real code base everything seems to get replaced correctly
> > now.
>
> Sounds good. I'm not sure that complicated const constructions are tested
> as well as they should be...
With your help I did some more adjustments and my semantic patch replaces
all the typedefed structs correctly, with a single exception. The sources
contain one line like this:
static const foo_t const foo_arry[] = {
...
};
Similar as before, foo_t should be replaced with 'struct foo_t',
but it's not.
Again, some complex const usage, though this time I'm almost certain that
the second const is meaningless. gcc consumes it, though, so does
'spatch --parse-c'.
Soren
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci