| 1 |
/// Description for the disj script. |
| 2 |
//# This is a limitation. |
| 3 |
//# This is another limitation. |
| 4 |
/// |
| 5 |
// Confidence: Moderate |
| 6 |
// Comments: This is to test disjunction generation. |
| 7 |
|
| 8 |
virtual patch |
| 9 |
virtual context |
| 10 |
virtual org |
| 11 |
virtual report |
| 12 |
|
| 13 |
@disj depends on patch && !context && !org && !report@ |
| 14 |
expression E1, E2, E3; |
| 15 |
identifier x; |
| 16 |
@@ |
| 17 |
|
| 18 |
if (E2 < |
| 19 |
- E3 |
| 20 |
+ E1 |
| 21 |
) { ... |
| 22 |
( |
| 23 |
some_function(0); |
| 24 |
x = 30; |
| 25 |
| |
| 26 |
some_function(1); |
| 27 |
x = 30; |
| 28 |
| |
| 29 |
- this(E1); |
| 30 |
+ that(E2); |
| 31 |
| |
| 32 |
- some_function(E1) |
| 33 |
+ another_function(E2) |
| 34 |
; |
| 35 |
- x = 30; |
| 36 |
) |
| 37 |
... } |
| 38 |
|
| 39 |
// ---------------------------------------------------------------------------- |
| 40 |
|
| 41 |
@disj_context depends on !patch && (context || org || report) exists@ |
| 42 |
identifier x; |
| 43 |
expression E1, E2, E3; |
| 44 |
position j0, j1; |
| 45 |
@@ |
| 46 |
|
| 47 |
if (E2@j0 < |
| 48 |
E3 |
| 49 |
) { ... |
| 50 |
( |
| 51 |
some_function(0); |
| 52 |
x = 30; |
| 53 |
| |
| 54 |
some_function(1); |
| 55 |
x = 30; |
| 56 |
| |
| 57 |
this@j1(E1); |
| 58 |
| |
| 59 |
some_function@j1(E1) |
| 60 |
; |
| 61 |
x = 30; |
| 62 |
) |
| 63 |
... } |
| 64 |
|
| 65 |
@disj_disj depends on !patch && (context || org || report)@ |
| 66 |
identifier x; |
| 67 |
expression E1, E2, E3; |
| 68 |
position disj_context.j0, disj_context.j1; |
| 69 |
@@ |
| 70 |
|
| 71 |
if (E2@j0 < |
| 72 |
* E3 |
| 73 |
) { ... |
| 74 |
( |
| 75 |
* this@j1(E1); |
| 76 |
| |
| 77 |
* some_function@j1(E1) |
| 78 |
; |
| 79 |
* x = 30; |
| 80 |
) |
| 81 |
... } |
| 82 |
|
| 83 |
// ---------------------------------------------------------------------------- |
| 84 |
|
| 85 |
@script:python disj_org depends on org@ |
| 86 |
j0 << disj_context.j0; |
| 87 |
j1 << disj_context.j1; |
| 88 |
@@ |
| 89 |
|
| 90 |
msg = "Org message. Found a match in disj rule." |
| 91 |
coccilib.org.print_todo(j0[0], msg) |
| 92 |
coccilib.org.print_link(j1[0], "") |
| 93 |
|
| 94 |
// ---------------------------------------------------------------------------- |
| 95 |
|
| 96 |
@script:python disj_report depends on report@ |
| 97 |
E1 << disj_context.E1; |
| 98 |
E2 << disj_context.E2; |
| 99 |
j0 << disj_context.j0; |
| 100 |
j1 << disj_context.j1; |
| 101 |
@@ |
| 102 |
|
| 103 |
msg = "Report message. Remove call to this(%s) and replace with call to that(%s) around line %s." % (E1,E2,j1[0].line) |
| 104 |
coccilib.report.print_report(j0[0], msg) |
| 105 |
|