Skip to content

Commit c7c0a73

Browse files
committed
Accept review suggestions
1 parent 52cc611 commit c7c0a73

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

go/ql/lib/semmle/go/dataflow/internal/DataFlowNodes.qll

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ module Public {
551551
}
552552

553553
/**
554-
* Gets the data flow node corresponding to an argument of this call, where
554+
* Gets a data flow node corresponding to an argument of this call, where
555555
* tuple extraction has been done but arguments corresponding to a variadic
556556
* parameter are still considered separate.
557557
*/
@@ -567,20 +567,17 @@ module Public {
567567
* For calls of the form `f(g())` where `g` has multiple results, the arguments of the call to
568568
* `i` are the (implicit) element extraction nodes for the call to `g`.
569569
*
570-
* For calls to variadic functions without an ellipsis (`...`), there is a single argument of type
571-
* `ImplicitVarargsSlice` corresponding to the variadic parameter. This is in contrast to the member
572-
* predicate `getArgument` on `CallExpr`, which gets the syntactic arguments.
570+
* Returns a single `Node` corresponding to a variadic parameter. If there is no corresponding
571+
* argument with an ellipsis (`...`), then it is a `ImplicitVarargsSlice`. This is in contrast
572+
* to `getArgument` on `CallExpr`, which gets the syntactic arguments. Use
573+
* `getSyntacticArgument` to get that behavior.
573574
*/
574575
Node getArgument(int i) {
575-
exists(int lastParamIndex | lastParamIndex = expr.getCalleeType().getNumParameter() - 1 |
576-
if
577-
expr.hasImplicitVarargs() and
578-
i >= lastParamIndex
579-
then
580-
result.(ImplicitVarargsSlice).getCallNode() = this and
581-
i = lastParamIndex
582-
else result = this.getSyntacticArgument(i)
583-
)
576+
result = this.getSyntacticArgument(i) and
577+
not (expr.hasImplicitVarargs() and i >= expr.getCalleeType().getNumParameter() - 1)
578+
or
579+
i = expr.getCalleeType().getNumParameter() - 1 and
580+
result.(ImplicitVarargsSlice).getCallNode() = this
584581
}
585582

586583
/** Gets the data flow node corresponding to an argument of this call. */

0 commit comments

Comments
 (0)