On Thu, 4 Sep 2014, Mitchell Cuddie wrote:
> Julia,
>
> I am putting together a patch to find instances of a switch on a pointer
> typed argument. The patch below seems to work unless the argument is a
> function pointer in which case it doesn't match. How does one match a
> function pointer.
A function pointer shouldn't matter. Check your code with spatch
--parse-c. Perhaps it is not parsing the containing function for some
other reason.
> Secondly is there a way to have it mark if x is any type other than int?
You can use two rules:
@bad@
int x; type t;
position p;
@@
switch@p ((t)x) { ... }
@r@
expression x; type t;
position p != bad.p;
@@
*switch@p ((t)x)
{ ... } // put your case pattern here
julia
> @r@
> expression *x; type t; position p1;
> @@
> * switch ((t)x)
> {
> case ...:@p1
> ...
> }
>
> Mitchell
>
>
> _______________________________________________
> Cocci mailing list
> [email protected]
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci