Files
codeql/java/ql/test/kotlin/library-tests/arrays/arrayCreations.ql
Chris Smowton 96f3ea460f Make varargs extraction more Java-like:
* Extract varargs as if they are ordinary positional arguments
* Adapt the QL that distinguishes varargs from ordinary arguments to account for Kotlin's varargs which can occur in the middle of the arg list
* Add a test checking dataflow through varargs which doesn't work yet due to array-get and array-set not being extracted as IndexExprs
* Extract the special case arrayOf(*x) as a clone call, which is (equivalent to) the Java lowering of that operation
2022-05-10 19:51:17 +01:00

19 lines
587 B
Plaintext

import java
query predicate arrayCreationTypes(ArrayCreationExpr ace, Type t, TypeAccess elementType) {
t = ace.getType() and elementType.getParent() = ace
}
query predicate arrayCreationDimensions(ArrayCreationExpr ace, Expr dimension, int dimensionIdx) {
ace.getDimension(dimensionIdx) = dimension
}
query predicate arrayCreationInit(ArrayCreationExpr ace, ArrayInit init, Expr e, int idx) {
ace.getInit() = init and
init.getInit(idx) = e
}
query predicate cloneCalls(MethodAccess ma, Type resultType) {
ma.getMethod().getName() = "clone" and resultType = ma.getType()
}