| 1 |
// This file is part of Coccinelle, lincensed under the terms of the GPL v2. |
| 2 |
// See copyright.txt in the Coccinelle source code for more information. |
| 3 |
// The Coccinelle source code can be obtained at http://coccinelle.lip6.fr |
| 4 |
|
| 5 |
/// Adds void to function headers with no arguments. |
| 6 |
//# If a matched function has a prototype declaration, the script will not |
| 7 |
//# match the prototype. |
| 8 |
/// |
| 9 |
// Confidence: High |
| 10 |
// URL: http://coccinelle.lip6.fr |
| 11 |
// Options: --recursive-includes |
| 12 |
|
| 13 |
virtual patch |
| 14 |
virtual context |
| 15 |
virtual org |
| 16 |
virtual report |
| 17 |
|
| 18 |
@addvoid depends on patch && !context && !org && !report@ |
| 19 |
identifier f; |
| 20 |
@@ |
| 21 |
|
| 22 |
f( |
| 23 |
+ void |
| 24 |
) { ... } |
| 25 |
|
| 26 |
// ---------------------------------------------------------------------------- |
| 27 |
|
| 28 |
@addvoid_context depends on !patch && (context || org || report)@ |
| 29 |
identifier f; |
| 30 |
position j0; |
| 31 |
@@ |
| 32 |
|
| 33 |
* f@j0( |
| 34 |
) { ... } |
| 35 |
|
| 36 |
// ---------------------------------------------------------------------------- |
| 37 |
|
| 38 |
@script:python addvoid_org depends on org@ |
| 39 |
f << addvoid_context.f; |
| 40 |
j0 << addvoid_context.j0; |
| 41 |
@@ |
| 42 |
|
| 43 |
msg = "WARNING: Zero-argument function \"%s\" should have void declaration. " % (f) |
| 44 |
coccilib.org.print_safe_todo(j0[0], msg) |
| 45 |
|
| 46 |
// ---------------------------------------------------------------------------- |
| 47 |
|
| 48 |
@script:python addvoid_report depends on report@ |
| 49 |
f << addvoid_context.f; |
| 50 |
j0 << addvoid_context.j0; |
| 51 |
@@ |
| 52 |
|
| 53 |
msg = "WARNING: Zero-argument function \"%s\" should have void declaration. " % (f) |
| 54 |
coccilib.report.print_report(j0[0], msg) |
| 55 |
|