Skip to content

Commit 8a435ae

Browse files
committed
C++: Autoformat "Declaration hides parameter"
1 parent 28261d6 commit 8a435ae

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

cpp/ql/src/Best Practices/Hiding/DeclarationHidesParameter.ql

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@
88
* @tags maintainability
99
* readability
1010
*/
11-
import cpp
1211

12+
import cpp
1313

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.
2121
ParameterDeclarationEntry functionParameterNames(Function f, string name) {
2222
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
2828
)
2929
}
3030

3131
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

Comments
 (0)