Skip to content

Commit da83f82

Browse files
committed
C++: Solve duplication in getParameterString().
1 parent ca0d23f commit da83f82

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
191191
result = ""
192192
or
193193
index = getNumberOfParameters() - 1 and
194-
result = getParameter(index).getTypedName()
194+
result = min(getParameter(index).getTypedName())
195195
or
196196
index < getNumberOfParameters() - 1 and
197-
result = getParameter(index).getTypedName() + ", " + getParameterStringFrom(index + 1)
197+
result = min(getParameter(index).getTypedName()) + ", " + getParameterStringFrom(index + 1)
198198
}
199199

200200
/** Gets a call to this function. */
@@ -623,11 +623,11 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl {
623623
result = ""
624624
or
625625
index = getNumberOfParameters() - 1 and
626-
result = getParameterDeclarationEntry(index).getTypedName()
626+
result = min(getParameterDeclarationEntry(index).getTypedName())
627627
or
628628
index < getNumberOfParameters() - 1 and
629629
result =
630-
getParameterDeclarationEntry(index).getTypedName() + ", " + getParameterStringFrom(index + 1)
630+
min(getParameterDeclarationEntry(index).getTypedName()) + ", " + getParameterStringFrom(index + 1)
631631
}
632632

633633
/**

cpp/ql/test/library-tests/functions/functions/Functions1.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,4 @@
2828
| functions.cpp:39:2:39:8 | MyClass | MyClass | MyClass && from | declaration:functions.cpp:39:2:39:8 |
2929
| functions.cpp:40:2:40:13 | operator int | operator int | | declaration:functions.cpp:40:2:40:13 |
3030
| functions.cpp:43:6:43:6 | h | h | int x | TopLevelFunction, declaration:functions.cpp:43:6:43:6, declaration:functions.cpp:44:6:44:6, isTopLevel |
31-
| functions.cpp:43:6:43:6 | h | h | int y | TopLevelFunction, declaration:functions.cpp:43:6:43:6, declaration:functions.cpp:44:6:44:6, isTopLevel |
3231
| functions.cpp:44:6:44:6 | h | h | int x | TopLevelFunction, declaration:functions.cpp:43:6:43:6, declaration:functions.cpp:44:6:44:6, isTopLevel |
33-
| functions.cpp:44:6:44:6 | h | h | int y | TopLevelFunction, declaration:functions.cpp:43:6:43:6, declaration:functions.cpp:44:6:44:6, isTopLevel |

0 commit comments

Comments
 (0)