Discussion:
[Cocci] Not pointer expression
Francois-Xavier Le Bail
2018-02-08 14:32:02 UTC
Permalink
Hi,

expression *e;
define 'e' is a pointer expression.

Is there a way to define 'e' is *not* a pointer expression?
--
Francois-Xavier
Julia Lawall
2018-02-08 14:44:52 UTC
Permalink
Post by Francois-Xavier Le Bail
Hi,
expression *e;
define 'e' is a pointer expression.
Is there a way to define 'e' is *not* a pointer expression?
@@
expression *e;
expression e1;
@@

(
e
|
*e1
)

The above will highlight all expressions that have not been inferred to
have a pointer type. But note that that doesn't mean that it has been
inferred that the expression as a non-pointer type. It could be that not
enough information is available.

Another option would be:

@@
expression *e;
type T;
T e1;
@@

(
e
|
*e1
)

Now it should require that e1 actually has a known type and it is not a
pointer type.

Another approach would be:

@bad@
position p;
expression *e;
@@

***@p

@ok@
position p != bad.p;
type T;
T e;
@@

****@p

If you are actually interested in structure types, you could also say

struct e;

julia
Post by Francois-Xavier Le Bail
--
Francois-Xavier
_______________________________________________
Cocci mailing list
https://systeme.lip6.fr/mailman/listinfo/cocci
Francois-Xavier Le Bail
2018-02-08 15:15:50 UTC
Permalink
Post by Francois-Xavier Le Bail
Post by Francois-Xavier Le Bail
Hi,
expression *e;
define 'e' is a pointer expression.
Is there a way to define 'e' is *not* a pointer expression?
@@
expression *e;
expression e1;
@@
(
e
|
*e1
)
The above will highlight all expressions that have not been inferred to
have a pointer type. But note that that doesn't mean that it has been
inferred that the expression as a non-pointer type. It could be that not
enough information is available.
@@
expression *e;
type T;
T e1;
@@
(
e
|
*e1
)
Now it should require that e1 actually has a known type and it is not a
pointer type.
@bad@
position p;
expression *e;
@@
@ok@
position p != bad.p;
type T;
T e;
@@
If you are actually interested in structure types, you could also say
struct e;
Thanks, I will do some tests with these different approaches.
--
Francois-Xavier
Loading...