| 1 |
/// Removes field and name struct fields from module_ calls. |
| 2 |
/// |
| 3 |
// Confidence: Low |
| 4 |
// Keywords: MACRO, .name, .field. |
| 5 |
|
| 6 |
virtual patch |
| 7 |
virtual context |
| 8 |
virtual org |
| 9 |
virtual report |
| 10 |
|
| 11 |
/* This file has interleaving of patch and non-patch rules. */ |
| 12 |
|
| 13 |
@match1@ |
| 14 |
declarer name module1; |
| 15 |
declarer name module2; |
| 16 |
identifier d; |
| 17 |
@@ |
| 18 |
|
| 19 |
( |
| 20 |
module1(d); |
| 21 |
| |
| 22 |
module2(d, ...); |
| 23 |
) |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
@fix1 depends on match1 && patch && !context && !org && !report@ |
| 28 |
identifier match1.d; |
| 29 |
@@ |
| 30 |
|
| 31 |
static struct struct_name d = { |
| 32 |
- .field = MACRO, |
| 33 |
}; |
| 34 |
|
| 35 |
|
| 36 |
@match2@ |
| 37 |
identifier d; |
| 38 |
@@ |
| 39 |
|
| 40 |
( |
| 41 |
module3(&d) |
| 42 |
| |
| 43 |
module4(&d, ...) |
| 44 |
| |
| 45 |
module5(&d, ...) |
| 46 |
) |
| 47 |
|
| 48 |
|
| 49 |
@fix2 depends on match2 && patch && !context && !org && !report@ |
| 50 |
identifier match2.d; |
| 51 |
@@ |
| 52 |
|
| 53 |
static struct struct_name d = { |
| 54 |
- .name = MACRO, |
| 55 |
}; |
| 56 |
|
| 57 |
// ---------------------------------------------------------------------------- |
| 58 |
|
| 59 |
@fix1_context depends on match1 && !patch && (context || org || report)@ |
| 60 |
identifier match1.d; |
| 61 |
position j0; |
| 62 |
@@ |
| 63 |
|
| 64 |
static struct struct_name d@j0 = { |
| 65 |
* .field = MACRO, |
| 66 |
}; |
| 67 |
|
| 68 |
@fix2_context depends on match2 && !patch && (context || org || report)@ |
| 69 |
identifier match2.d; |
| 70 |
position j0; |
| 71 |
@@ |
| 72 |
|
| 73 |
static struct struct_name d@j0 = { |
| 74 |
* .name = MACRO, |
| 75 |
}; |
| 76 |
|
| 77 |
// ---------------------------------------------------------------------------- |
| 78 |
|
| 79 |
@script:python fix1_org depends on org@ |
| 80 |
d << match1.d; |
| 81 |
j0 << fix1_context.j0; |
| 82 |
@@ |
| 83 |
|
| 84 |
msg = "Found .field = MACRO for identifier %s " % (d) |
| 85 |
coccilib.org.print_safe_todo(j0[0], msg) |
| 86 |
|
| 87 |
@script:python fix2_org depends on org@ |
| 88 |
d << match2.d; |
| 89 |
j0 << fix2_context.j0; |
| 90 |
@@ |
| 91 |
|
| 92 |
msg = "Found .name = MACRO for identifier %s " % (d) |
| 93 |
coccilib.org.print_safe_todo(j0[0], msg) |
| 94 |
|
| 95 |
// ---------------------------------------------------------------------------- |
| 96 |
|
| 97 |
@script:python fix1_report depends on report@ |
| 98 |
d << match1.d; |
| 99 |
j0 << fix1_context.j0; |
| 100 |
@@ |
| 101 |
|
| 102 |
msg = "Found .field = MACRO for identifier %s " % (d) |
| 103 |
coccilib.report.print_report(j0[0], msg) |
| 104 |
|
| 105 |
@script:python fix2_report depends on report@ |
| 106 |
d << match2.d; |
| 107 |
j0 << fix2_context.j0; |
| 108 |
@@ |
| 109 |
|
| 110 |
msg = "Found .name = MACRO for identifier %s " % (d) |
| 111 |
coccilib.report.print_report(j0[0], msg) |
| 112 |
|