2012-04-22 02:23:48 +08:00
|
|
|
/// sizeof when applied to a pointer typed expression gives the size of
|
|
|
|
/// the pointer
|
|
|
|
///
|
|
|
|
// Confidence: High
|
|
|
|
// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
|
|
|
|
// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
|
|
|
|
// URL: http://coccinelle.lip6.fr/
|
|
|
|
// Comments:
|
2013-06-20 19:10:56 +08:00
|
|
|
// Options: --no-includes --include-headers
|
2012-04-22 02:23:48 +08:00
|
|
|
|
|
|
|
virtual org
|
|
|
|
virtual report
|
|
|
|
virtual context
|
|
|
|
virtual patch
|
|
|
|
|
|
|
|
@depends on patch@
|
|
|
|
expression *x;
|
|
|
|
expression f;
|
2016-05-24 12:19:17 +08:00
|
|
|
expression i;
|
2012-04-22 02:23:48 +08:00
|
|
|
type T;
|
|
|
|
@@
|
|
|
|
|
|
|
|
(
|
|
|
|
x = <+... sizeof(
|
|
|
|
- x
|
|
|
|
+ *x
|
|
|
|
) ...+>
|
|
|
|
|
|
|
|
|
f(...,(T)(x),...,sizeof(
|
|
|
|
- x
|
|
|
|
+ *x
|
|
|
|
),...)
|
|
|
|
|
|
2016-05-24 12:19:17 +08:00
|
|
|
f(...,sizeof(
|
|
|
|
- x
|
|
|
|
+ *x
|
|
|
|
),...,(T)(x),...)
|
|
|
|
|
|
|
|
|
f(...,(T)(x),...,i*sizeof(
|
2012-04-22 02:23:48 +08:00
|
|
|
- x
|
|
|
|
+ *x
|
|
|
|
),...)
|
2016-05-24 12:19:17 +08:00
|
|
|
|
|
|
|
|
f(...,i*sizeof(
|
|
|
|
- x
|
|
|
|
+ *x
|
|
|
|
),...,(T)(x),...)
|
2012-04-22 02:23:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
@r depends on !patch@
|
|
|
|
expression *x;
|
|
|
|
expression f;
|
2016-05-24 12:19:17 +08:00
|
|
|
expression i;
|
2012-04-22 02:23:48 +08:00
|
|
|
position p;
|
|
|
|
type T;
|
|
|
|
@@
|
|
|
|
|
|
|
|
(
|
|
|
|
*x = <+... sizeof@p(x) ...+>
|
|
|
|
|
|
|
|
|
*f(...,(T)(x),...,sizeof@p(x),...)
|
|
|
|
|
|
|
|
|
*f(...,sizeof@p(x),...,(T)(x),...)
|
2016-05-24 12:19:17 +08:00
|
|
|
|
|
|
|
|
*f(...,(T)(x),...,i*sizeof@p(x),...)
|
|
|
|
|
|
|
|
|
*f(...,i*sizeof@p(x),...,(T)(x),...)
|
2012-04-22 02:23:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
@script:python depends on org@
|
|
|
|
p << r.p;
|
|
|
|
@@
|
|
|
|
|
|
|
|
cocci.print_main("application of sizeof to pointer",p)
|
|
|
|
|
|
|
|
@script:python depends on report@
|
|
|
|
p << r.p;
|
|
|
|
@@
|
|
|
|
|
|
|
|
msg = "ERROR: application of sizeof to pointer"
|
|
|
|
coccilib.report.print_report(p[0],msg)
|