Coccinelle archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] Q: does spatch understand typeof?
@ 2020-01-15 11:25 Oleg Nesterov
  2020-01-15 12:09 ` Julia Lawall
  0 siblings, 1 reply; 8+ messages in thread
From: Oleg Nesterov @ 2020-01-15 11:25 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

Hello,

trivial example:

	@r@
	int x;
	@@

	* x = 0;

C code:

	void f(void)
	{
		int a;
		__typeof__(a) b;

		a = 0;		// this matches
		b = 0;		// this doesn't
	}

is it correct?

Thanks,

Oleg.

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Cocci] Q: does spatch understand typeof?
  2020-01-15 11:25 [Cocci] Q: does spatch understand typeof? Oleg Nesterov
@ 2020-01-15 12:09 ` Julia Lawall
  2020-01-15 15:30   ` Oleg Nesterov
  0 siblings, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2020-01-15 12:09 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Julia Lawall, cocci

On Wed, 15 Jan 2020, Oleg Nesterov wrote:

> Hello,
>
> trivial example:
>
> 	@r@
> 	int x;
> 	@@
>
> 	* x = 0;
>
> C code:
>
> 	void f(void)
> 	{
> 		int a;
> 		__typeof__(a) b;
>
> 		a = 0;		// this matches
> 		b = 0;		// this doesn't
> 	}
>
> is it correct?

Yes, it doesn't currently understand typeof.  If it's a big problem, it
should be easy to fix.

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Cocci] Q: does spatch understand typeof?
  2020-01-15 12:09 ` Julia Lawall
@ 2020-01-15 15:30   ` Oleg Nesterov
  2020-01-15 15:45     ` Julia Lawall
  2020-01-15 15:53     ` Oleg Nesterov
  0 siblings, 2 replies; 8+ messages in thread
From: Oleg Nesterov @ 2020-01-15 15:30 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Julia Lawall, cocci

On 01/15, Julia Lawall wrote:
>
> Yes, it doesn't currently understand typeof.  If it's a big problem, it
> should be easy to fix.

OK, thanks Julia.

Another question...

inc.h:

	struct TTT { int mem; } *ptr;

test.c:

	#include "inc.h"

	void func(void)
	{
		ptr->mem = 0;
	}

test.cocci:

	@r@
	struct TTT *p;
	@@

	* p->mem

$ spatch --sp-file test.cocci test.c

	(ONCE) Expected tokens mem TTT
	Skipping: test.c

I tried to play with various --.*include.* options, but nothing seems to work
unless I add "inc.h" to the command line explicitly.

Oleg.

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Cocci] Q: does spatch understand typeof?
  2020-01-15 15:30   ` Oleg Nesterov
@ 2020-01-15 15:45     ` Julia Lawall
  2020-01-15 15:59       ` Oleg Nesterov
  2020-01-15 15:53     ` Oleg Nesterov
  1 sibling, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2020-01-15 15:45 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: cocci



On Wed, 15 Jan 2020, Oleg Nesterov wrote:

> On 01/15, Julia Lawall wrote:
> >
> > Yes, it doesn't currently understand typeof.  If it's a big problem, it
> > should be easy to fix.
>
> OK, thanks Julia.
>
> Another question...
>
> inc.h:
>
> 	struct TTT { int mem; } *ptr;
>
> test.c:
>
> 	#include "inc.h"
>
> 	void func(void)
> 	{
> 		ptr->mem = 0;
> 	}
>
> test.cocci:
>
> 	@r@
> 	struct TTT *p;
> 	@@
>
> 	* p->mem
>
> $ spatch --sp-file test.cocci test.c
>
> 	(ONCE) Expected tokens mem TTT
> 	Skipping: test.c
>
> I tried to play with various --.*include.* options, but nothing seems to work
> unless I add "inc.h" to the command line explicitly.

The problem is that the file filtering happens before the parsing, and it
is the parsing that finds the includes.  You can disable the file
filtering with --disable-worth-trying-opt.

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Cocci] Q: does spatch understand typeof?
  2020-01-15 15:30   ` Oleg Nesterov
  2020-01-15 15:45     ` Julia Lawall
@ 2020-01-15 15:53     ` Oleg Nesterov
  2020-01-15 15:59       ` Julia Lawall
  1 sibling, 1 reply; 8+ messages in thread
From: Oleg Nesterov @ 2020-01-15 15:53 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Julia Lawall, cocci

On 01/15, Oleg Nesterov wrote:
>
> Another question...

Oh, and another one ;)

http://coccinelle.lip6.fr/docs/main_grammar006.html mentions
"typeof(expr/ctype)", but I failed to find any doc/example of
how can it be used in SPL.

Could you explain it?

Oleg.

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Cocci] Q: does spatch understand typeof?
  2020-01-15 15:45     ` Julia Lawall
@ 2020-01-15 15:59       ` Oleg Nesterov
  2020-01-15 16:00         ` Julia Lawall
  0 siblings, 1 reply; 8+ messages in thread
From: Oleg Nesterov @ 2020-01-15 15:59 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

On 01/15, Julia Lawall wrote:
>
> On Wed, 15 Jan 2020, Oleg Nesterov wrote:
>
> > $ spatch --sp-file test.cocci test.c
> >
> > 	(ONCE) Expected tokens mem TTT
> > 	Skipping: test.c
> >
> > I tried to play with various --.*include.* options, but nothing seems to work
> > unless I add "inc.h" to the command line explicitly.
>
> The problem is that the file filtering happens before the parsing, and it
> is the parsing that finds the includes.

Yes, thanks, this was clear to me,

> You can disable the file
> filtering with --disable-worth-trying-opt.

Heh. I swear, I even did

	$ spatch --longhelp 2>&1 | grep disable

but apparently I can't read.

Thanks a lot!

Oleg.

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Cocci] Q: does spatch understand typeof?
  2020-01-15 15:53     ` Oleg Nesterov
@ 2020-01-15 15:59       ` Julia Lawall
  0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2020-01-15 15:59 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: cocci



On Wed, 15 Jan 2020, Oleg Nesterov wrote:

> On 01/15, Oleg Nesterov wrote:
> >
> > Another question...
>
> Oh, and another one ;)
>
> http://coccinelle.lip6.fr/docs/main_grammar006.html mentions
> "typeof(expr/ctype)", but I failed to find any doc/example of
> how can it be used in SPL.
>
> Could you explain it?

@@
@@

- typeof(foo) x;

That is, you can match against the above code.  But there is no evaluation
of what typeof(foo) actually means.

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Cocci] Q: does spatch understand typeof?
  2020-01-15 15:59       ` Oleg Nesterov
@ 2020-01-15 16:00         ` Julia Lawall
  0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2020-01-15 16:00 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: cocci



On Wed, 15 Jan 2020, Oleg Nesterov wrote:

> On 01/15, Julia Lawall wrote:
> >
> > On Wed, 15 Jan 2020, Oleg Nesterov wrote:
> >
> > > $ spatch --sp-file test.cocci test.c
> > >
> > > 	(ONCE) Expected tokens mem TTT
> > > 	Skipping: test.c
> > >
> > > I tried to play with various --.*include.* options, but nothing seems to work
> > > unless I add "inc.h" to the command line explicitly.
> >
> > The problem is that the file filtering happens before the parsing, and it
> > is the parsing that finds the includes.
>
> Yes, thanks, this was clear to me,
>
> > You can disable the file
> > filtering with --disable-worth-trying-opt.
>
> Heh. I swear, I even did
>
> 	$ spatch --longhelp 2>&1 | grep disable
>
> but apparently I can't read.

The name is not super intuitive, and is more tied to the code than the
user intuition.  I spent some time searching for -no- and for something
about files.

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, back to index

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 11:25 [Cocci] Q: does spatch understand typeof? Oleg Nesterov
2020-01-15 12:09 ` Julia Lawall
2020-01-15 15:30   ` Oleg Nesterov
2020-01-15 15:45     ` Julia Lawall
2020-01-15 15:59       ` Oleg Nesterov
2020-01-15 16:00         ` Julia Lawall
2020-01-15 15:53     ` Oleg Nesterov
2020-01-15 15:59       ` Julia Lawall

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git