1/// Find &&/|| operations that include the same argument more than once
2//# A common source of false positives is when the expression, or
3//# another expresssion in the same && or || operation, performs a
4//# side effect.
5///
6// Confidence: Moderate
7// Copyright: (C) 2010 Nicolas Palix, DIKU.  GPLv2.
8// Copyright: (C) 2010 Julia Lawall, DIKU.  GPLv2.
9// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
10// URL: http://coccinelle.lip6.fr/
11// Comments:
12// Options: --no-includes --include-headers
13
14virtual context
15virtual org
16virtual report
17
18@r expression@
19expression E;
20position p;
21@@
22
23(
24 E@p || ... || E
25|
26 E@p && ... && E
27)
28
29@bad@
30expression r.E,e1,e2,fn;
31position r.p;
32assignment operator op;
33@@
34
35(
36E@p
37&
38 <+... \(fn(...)\|e1 op e2\|e1++\|e1--\|++e1\|--e1\) ...+>
39)
40
41@depends on context && !bad@
42expression r.E;
43position r.p;
44@@
45
46*E@p
47
48@script:python depends on org && !bad@
49p << r.p;
50@@
51
52cocci.print_main("duplicated argument to && or ||",p)
53
54@script:python depends on report && !bad@
55p << r.p;
56@@
57
58coccilib.report.print_report(p[0],"duplicated argument to && or ||")
59