1 /// Move constants to the right of binary operators.
2 //# Depends on personal taste in some cases.
4 // Confidence: Moderate
5 // Copyright: (C) 2015 Copyright: (C) 2015 Julia Lawall, Inria. GPLv2.
6 // URL: http://coccinelle.lip6.fr/
7 // Options: --no-includes --include-headers
14 @r1 depends on patch && !context && !org && !report
15 disable bitor_comm, neg_if_exp@
19 binary operator b = {==,!=,&,|};
43 @r2 depends on patch && !context && !org && !report
44 disable gtr_lss, gtr_lss_eq, not_int2@
48 binary operator b1 = {<,<=},b2 = {<,<=};
49 binary operator b3 = {>,>=},b4 = {>,>=};
61 (e1 b1 e) && (e b2 e2)
63 (e1 b3 e) && (e b4 e2)
80 // ----------------------------------------------------------------------------
82 @r1_context depends on !patch && (context || org || report)
83 disable bitor_comm, neg_if_exp exists@
85 binary operator b = {==,!=,&,|};
108 @r2_context depends on !patch && (context || org || report)
109 disable gtr_lss, gtr_lss_eq, not_int2 exists@
111 binary operator b, b1 = {<,<=}, b2 = {<,<=}, b3 = {>,>=}, b4 = {>,>=};
113 expression e, e1, e2;
114 local idexpression i;
125 (e1 b1 e) && (e b2 e2)
127 (e1 b3 e) && (e b4 e2)
140 // ----------------------------------------------------------------------------
142 @script:python r1_org depends on org@
146 msg = "Move constant to right."
147 coccilib.org.print_todo(j0[0], msg)
149 @script:python r2_org depends on org@
153 msg = "Move constant to right."
154 coccilib.org.print_todo(j0[0], msg)
156 // ----------------------------------------------------------------------------
158 @script:python r1_report depends on report@
162 msg = "Move constant to right."
163 coccilib.report.print_report(j0[0], msg)
165 @script:python r2_report depends on report@
169 msg = "Move constant to right."
170 coccilib.report.print_report(j0[0], msg)