|
8 | 8 | * @tags maintainability |
9 | 9 | * readability |
10 | 10 | */ |
11 | | -import cpp |
12 | 11 |
|
| 12 | +import cpp |
13 | 13 |
|
14 | | -/* Names of parameters in the implementation of a function. |
15 | | - Notice that we need to exclude parameter names used in prototype |
16 | | - declarations and only include the ones from the actual definition. |
17 | | - We also exclude names from functions that have multiple definitions. |
18 | | - This should not happen in a single application but since we |
19 | | - have a system wide view it is likely to happen for instance for |
20 | | - the main function. */ |
| 14 | +// Names of parameters in the implementation of a function. |
| 15 | +// Notice that we need to exclude parameter names used in prototype |
| 16 | +// declarations and only include the ones from the actual definition. |
| 17 | +// We also exclude names from functions that have multiple definitions. |
| 18 | +// This should not happen in a single application but since we |
| 19 | +// have a system wide view it is likely to happen for instance for |
| 20 | +// the main function. |
21 | 21 | ParameterDeclarationEntry functionParameterNames(Function f, string name) { |
22 | 22 | exists(FunctionDeclarationEntry fe | |
23 | | - result.getFunctionDeclarationEntry() = fe |
24 | | - and fe.getFunction() = f |
25 | | - and fe.getLocation() = f.getDefinitionLocation() |
26 | | - and strictcount(f.getDefinitionLocation()) = 1 |
27 | | - and result.getName() = name |
| 23 | + result.getFunctionDeclarationEntry() = fe and |
| 24 | + fe.getFunction() = f and |
| 25 | + fe.getLocation() = f.getDefinitionLocation() and |
| 26 | + strictcount(f.getDefinitionLocation()) = 1 and |
| 27 | + result.getName() = name |
28 | 28 | ) |
29 | 29 | } |
30 | 30 |
|
31 | 31 | from Function f, LocalVariable lv, ParameterDeclarationEntry pde |
32 | | -where f = lv.getFunction() and |
33 | | - pde = functionParameterNames(f, lv.getName()) and |
34 | | - not lv.isInMacroExpansion() |
35 | | -select lv, "Local variable '"+ lv.getName() +"' hides a $@.", |
36 | | - pde, "parameter of the same name" |
| 32 | +where |
| 33 | + f = lv.getFunction() and |
| 34 | + pde = functionParameterNames(f, lv.getName()) and |
| 35 | + not lv.isInMacroExpansion() |
| 36 | +select lv, "Local variable '" + lv.getName() + "' hides a $@.", pde, "parameter of the same name" |
0 commit comments