aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2018-05-21 02:58:59 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-05-22 10:00:23 -0400
commit21195f8e9a473035dc692a40a145f4f083fe5c1f (patch)
tree65eb26573939cfa05f5f446bd7e4c05b36389a0f
parent32d0572a75c81a2c70394f9e110ca080b9a733b1 (diff)
coccinelle: deref_null: improve performance
Move rules looking for some special cases of safe dereferences before the collection of NULL-tested values. The special cases are fairly rare, but somewhat costly to find, because isomorphisms create many variants of the rules. There is thus no need to search for them over and over for each NULL tested expression. Collecting them just once is sufficient and more efficient. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r--scripts/coccinelle/null/deref_null.cocci40
1 files changed, 20 insertions, 20 deletions
diff --git a/scripts/coccinelle/null/deref_null.cocci b/scripts/coccinelle/null/deref_null.cocci
index b16ccb7663a7..cbc6184e69ef 100644
--- a/scripts/coccinelle/null/deref_null.cocci
+++ b/scripts/coccinelle/null/deref_null.cocci
@@ -14,18 +14,10 @@ virtual context
14virtual org 14virtual org
15virtual report 15virtual report
16 16
17@ifm@
18expression *E;
19statement S1,S2;
20position p1;
21@@
22
23if@p1 ((E == NULL && ...) || ...) S1 else S2
24
25// The following two rules are separate, because both can match a single 17// The following two rules are separate, because both can match a single
26// expression in different ways 18// expression in different ways
27@pr1 expression@ 19@pr1 expression@
28expression *ifm.E; 20expression E;
29identifier f; 21identifier f;
30position p1; 22position p1;
31@@ 23@@
@@ -33,7 +25,7 @@ position p1;
33 (E != NULL && ...) ? <+...E->f@p1...+> : ... 25 (E != NULL && ...) ? <+...E->f@p1...+> : ...
34 26
35@pr2 expression@ 27@pr2 expression@
36expression *ifm.E; 28expression E;
37identifier f; 29identifier f;
38position p2; 30position p2;
39@@ 31@@
@@ -46,6 +38,14 @@ position p2;
46 sizeof(<+...E->f@p2...+>) 38 sizeof(<+...E->f@p2...+>)
47) 39)
48 40
41@ifm@
42expression *E;
43statement S1,S2;
44position p1;
45@@
46
47if@p1 ((E == NULL && ...) || ...) S1 else S2
48
49// For org and report modes 49// For org and report modes
50 50
51@r depends on !context && (org || report) exists@ 51@r depends on !context && (org || report) exists@
@@ -212,16 +212,8 @@ else S3
212// The following three rules are duplicates of ifm, pr1 and pr2 respectively. 212// The following three rules are duplicates of ifm, pr1 and pr2 respectively.
213// It is need because the previous rule as already made a "change". 213// It is need because the previous rule as already made a "change".
214 214
215@ifm1 depends on context && !org && !report@
216expression *E;
217statement S1,S2;
218position p1;
219@@
220
221if@p1 ((E == NULL && ...) || ...) S1 else S2
222
223@pr11 depends on context && !org && !report expression@ 215@pr11 depends on context && !org && !report expression@
224expression *ifm1.E; 216expression E;
225identifier f; 217identifier f;
226position p1; 218position p1;
227@@ 219@@
@@ -229,7 +221,7 @@ position p1;
229 (E != NULL && ...) ? <+...E->f@p1...+> : ... 221 (E != NULL && ...) ? <+...E->f@p1...+> : ...
230 222
231@pr12 depends on context && !org && !report expression@ 223@pr12 depends on context && !org && !report expression@
232expression *ifm1.E; 224expression E;
233identifier f; 225identifier f;
234position p2; 226position p2;
235@@ 227@@
@@ -242,6 +234,14 @@ position p2;
242 sizeof(<+...E->f@p2...+>) 234 sizeof(<+...E->f@p2...+>)
243) 235)
244 236
237@ifm1 depends on context && !org && !report@
238expression *E;
239statement S1,S2;
240position p1;
241@@
242
243if@p1 ((E == NULL && ...) || ...) S1 else S2
244
245@depends on context && !org && !report exists@ 245@depends on context && !org && !report exists@
246expression subE <= ifm1.E; 246expression subE <= ifm1.E;
247expression *ifm1.E; 247expression *ifm1.E;