|
1 | 1 | /** |
2 | | -* A library for identifying parameters which may be unused. |
3 | | -*/ |
| 2 | + * A library for identifying parameters which may be unused. |
| 3 | + */ |
4 | 4 |
|
5 | 5 | import cpp |
6 | 6 |
|
7 | 7 | /** |
8 | | -* A `Parameter` which is "usable" within the function. |
9 | | -* |
10 | | -* For this to be the case, the `Function` must have a definition, and that definition must include |
11 | | -* a body block, and the parameter must be a named parameter. |
12 | | -*/ |
| 8 | + * A `Parameter` which is "usable" within the function. |
| 9 | + * |
| 10 | + * For this to be the case, the `Function` must have a definition, and that definition must include |
| 11 | + * a body block, and the parameter must be a named parameter. |
| 12 | + */ |
13 | 13 | class UsableParameter extends Parameter { |
14 | 14 | UsableParameter() { |
15 | 15 | ( |
16 | 16 | /* Regular Function */ |
17 | 17 | // Find the function associated with the parameter |
18 | | - exists(Function f | this = f.getAParameter() | |
| 18 | + exists(Function f | this = f.getAParameter() | |
19 | 19 | // Must have the definition of the function, not just the declaration |
20 | | - f.hasDefinition() and |
| 20 | + f.hasDefinition() and |
21 | 21 | // There must be a body block associated with the function, otherwise the parameter cannot |
22 | 22 | // possibly be used |
23 | | - exists(f.getBlock()) |
24 | | - ) |
25 | | - or |
| 23 | + exists(f.getBlock()) |
| 24 | + ) |
| 25 | + or |
26 | 26 | /* Lambda Expression */ |
27 | 27 | // Find the function associated with the parameter |
28 | | - exists(LambdaExpression lambda, Function f | |
29 | | - this = lambda.getLambdaFunction().getParameter(_) |
30 | | - | |
| 28 | + exists(LambdaExpression lambda, Function f | |
| 29 | + this = lambda.getLambdaFunction().getParameter(_) |
| 30 | + | |
31 | 31 | // Must have the definition of the function, not just the declaration |
32 | | - lambda.getLambdaFunction() = f and |
33 | | - f.hasDefinition() and |
| 32 | + lambda.getLambdaFunction() = f and |
| 33 | + f.hasDefinition() and |
34 | 34 | // There must be a body block associated with the function, otherwise the parameter cannot |
35 | 35 | // possibly be used |
36 | | - exists(f.getBlock()) |
37 | | - ) |
38 | | - ) and |
| 36 | + exists(f.getBlock()) |
| 37 | + ) |
| 38 | + ) and |
39 | 39 | // Must be a named parameter, because unnamed parameters cannot be referenced |
40 | 40 | isNamed() |
41 | 41 | } |
42 | 42 | } |
43 | 43 |
|
44 | 44 | /** |
45 | | -* A `Parameter` which is usable but not directly used in the local context. |
46 | | -*/ |
| 45 | + * A `Parameter` which is usable but not directly used in the local context. |
| 46 | + */ |
47 | 47 | class UnusedParameter extends UsableParameter { |
48 | 48 | UnusedParameter() { not this instanceof UsedParameter } |
49 | 49 | } |
50 | 50 |
|
51 | 51 | /** |
52 | | -* A `Parameter` which is used in the local context. |
53 | | -*/ |
| 52 | + * A `Parameter` which is used in the local context. |
| 53 | + */ |
54 | 54 | class UsedParameter extends UsableParameter { |
55 | 55 | UsedParameter() { |
56 | 56 | // An access to the parameter exists in the function body |
|
0 commit comments