Skip to content

Commit 9238503

Browse files
committed
C++: Make unnamed parameters follow the "(unnamed ...)" naming
1 parent 7680080 commit 9238503

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cpp/ql/src/semmle/code/cpp/Parameter.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Parameter extends LocalScopeVariable, @parameter {
3636
* 1. The name given to the parameter at the function's definition or
3737
* (for catch block parameters) at the catch block.
3838
* 2. A name given to the parameter at a function declaration.
39-
* 3. The name "p#i" where i is the index of the parameter.
39+
* 3. The name "(unnamed parameter i)" where i is the index of the parameter.
4040
*/
4141
override string getName() {
4242
exists(VariableDeclarationEntry vde |
@@ -46,7 +46,7 @@ class Parameter extends LocalScopeVariable, @parameter {
4646
)
4747
or
4848
not exists(getANamedDeclarationEntry()) and
49-
result = "p#" + this.getIndex().toString()
49+
result = "(unnamed parameter " + this.getIndex().toString() + ")"
5050
}
5151

5252
override string getAPrimaryQlClass() { result = "Parameter" }
@@ -111,7 +111,8 @@ class Parameter extends LocalScopeVariable, @parameter {
111111
* Holds if this parameter has a name.
112112
*
113113
* In other words, this predicate holds precisely when the result of
114-
* `getName()` is not "p#i" (where `i` is the index of the parameter).
114+
* `getName()` is not "(unnamed parameter i)" (where `i` is the index
115+
* of the parameter).
115116
*/
116117
predicate isNamed() { exists(getANamedDeclarationEntry()) }
117118

0 commit comments

Comments
 (0)