mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
Fix extraction of data classes with array members
These use compiler-internal intrinsics at the IR layer, which are later lowered to java.util.Arrays calls. This performs that lowering in the same manner.
This commit is contained in:
committed by
Ian Lynagh
parent
ae2ca183cc
commit
aab271d81e
138
java/ql/test/kotlin/library-tests/data-classes/PrintAst.expected
Normal file
138
java/ql/test/kotlin/library-tests/data-classes/PrintAst.expected
Normal file
@@ -0,0 +1,138 @@
|
||||
dc.kt:
|
||||
# 0| [CompilationUnit] dc
|
||||
# 1| 1: [Class] ProtoMapValue
|
||||
# 0| 1: [Method] component1
|
||||
# 0| 5: [BlockStmt] { ... }
|
||||
# 0| 0: [ReturnStmt] return ...
|
||||
# 0| 0: [VarAccess] this.bytes
|
||||
# 0| -1: [ThisAccess] this
|
||||
# 0| 1: [Method] component2
|
||||
# 0| 5: [BlockStmt] { ... }
|
||||
# 0| 0: [ReturnStmt] return ...
|
||||
# 0| 0: [VarAccess] this.strs
|
||||
# 0| -1: [ThisAccess] this
|
||||
# 0| 1: [Method] copy
|
||||
#-----| 4: (Parameters)
|
||||
# 1| 0: [Parameter] bytes
|
||||
# 1| 1: [Parameter] strs
|
||||
# 0| 5: [BlockStmt] { ... }
|
||||
# 0| 0: [ReturnStmt] return ...
|
||||
# 0| 0: [ClassInstanceExpr] new ProtoMapValue(...)
|
||||
# 0| -3: [TypeAccess] ProtoMapValue
|
||||
# 0| 0: [VarAccess] bytes
|
||||
# 0| 1: [VarAccess] strs
|
||||
# 0| 1: [Method] toString
|
||||
# 0| 5: [BlockStmt] { ... }
|
||||
# 0| 0: [ReturnStmt] return ...
|
||||
# 0| 0: [StringTemplateExpr] "..."
|
||||
# 0| 0: [StringLiteral] ProtoMapValue(
|
||||
# 0| 1: [StringLiteral] bytes=
|
||||
# 0| 2: [MethodAccess] toString(...)
|
||||
# 0| -1: [TypeAccess] Arrays
|
||||
# 0| 0: [VarAccess] this.bytes
|
||||
# 0| -1: [ThisAccess] this
|
||||
# 0| 3: [StringLiteral] ,
|
||||
# 0| 4: [StringLiteral] strs=
|
||||
# 0| 5: [MethodAccess] toString(...)
|
||||
# 0| -1: [TypeAccess] Arrays
|
||||
# 0| 0: [VarAccess] this.strs
|
||||
# 0| -1: [ThisAccess] this
|
||||
# 0| 6: [StringLiteral] )
|
||||
# 0| 1: [Method] hashCode
|
||||
# 0| 5: [BlockStmt] { ... }
|
||||
# 0| 0: [LocalVariableDeclStmt] var ...;
|
||||
# 0| 1: [LocalVariableDeclExpr] result
|
||||
# 0| 0: [MethodAccess] hashCode(...)
|
||||
# 0| -1: [TypeAccess] Arrays
|
||||
# 0| 0: [VarAccess] this.bytes
|
||||
# 0| -1: [ThisAccess] this
|
||||
# 0| 1: [ExprStmt] <Expr>;
|
||||
# 0| 0: [AssignExpr] ...=...
|
||||
# 0| 0: [VarAccess] result
|
||||
# 0| 1: [MethodAccess] plus(...)
|
||||
# 0| -1: [MethodAccess] times(...)
|
||||
# 0| -1: [VarAccess] result
|
||||
# 0| 0: [IntegerLiteral] 31
|
||||
# 0| 0: [MethodAccess] hashCode(...)
|
||||
# 0| -1: [TypeAccess] Arrays
|
||||
# 0| 0: [VarAccess] this.strs
|
||||
# 0| -1: [ThisAccess] this
|
||||
# 0| 2: [ReturnStmt] return ...
|
||||
# 0| 0: [VarAccess] result
|
||||
# 0| 1: [Method] equals
|
||||
#-----| 4: (Parameters)
|
||||
# 0| 0: [Parameter] other
|
||||
# 0| 5: [BlockStmt] { ... }
|
||||
# 0| 0: [ExprStmt] <Expr>;
|
||||
# 0| 0: [WhenExpr] when ...
|
||||
# 0| 0: [WhenBranch] ... -> ...
|
||||
# 0| 0: [EQExpr] ... == ...
|
||||
# 0| 0: [ThisAccess] this
|
||||
# 0| 1: [VarAccess] other
|
||||
# 0| 1: [ReturnStmt] return ...
|
||||
# 0| 0: [BooleanLiteral] true
|
||||
# 0| 1: [ExprStmt] <Expr>;
|
||||
# 0| 0: [WhenExpr] when ...
|
||||
# 0| 0: [WhenBranch] ... -> ...
|
||||
# 0| 0: [NotInstanceOfExpr] ... !is ...
|
||||
# 0| 0: [VarAccess] other
|
||||
# 0| 1: [TypeAccess] ProtoMapValue
|
||||
# 0| 1: [ReturnStmt] return ...
|
||||
# 0| 0: [BooleanLiteral] false
|
||||
# 0| 2: [LocalVariableDeclStmt] var ...;
|
||||
# 0| 1: [LocalVariableDeclExpr] tmp0_other_with_cast
|
||||
# 0| 0: [CastExpr] (...)...
|
||||
# 0| 0: [TypeAccess] ProtoMapValue
|
||||
# 0| 1: [VarAccess] other
|
||||
# 0| 3: [ExprStmt] <Expr>;
|
||||
# 0| 0: [WhenExpr] when ...
|
||||
# 0| 0: [WhenBranch] ... -> ...
|
||||
# 0| 0: [ValueNEExpr] ... (value not-equals) ...
|
||||
# 0| 0: [VarAccess] this.bytes
|
||||
# 0| -1: [ThisAccess] this
|
||||
# 0| 1: [VarAccess] tmp0_other_with_cast.bytes
|
||||
# 0| -1: [VarAccess] tmp0_other_with_cast
|
||||
# 0| 1: [ReturnStmt] return ...
|
||||
# 0| 0: [BooleanLiteral] false
|
||||
# 0| 4: [ExprStmt] <Expr>;
|
||||
# 0| 0: [WhenExpr] when ...
|
||||
# 0| 0: [WhenBranch] ... -> ...
|
||||
# 0| 0: [ValueNEExpr] ... (value not-equals) ...
|
||||
# 0| 0: [VarAccess] this.strs
|
||||
# 0| -1: [ThisAccess] this
|
||||
# 0| 1: [VarAccess] tmp0_other_with_cast.strs
|
||||
# 0| -1: [VarAccess] tmp0_other_with_cast
|
||||
# 0| 1: [ReturnStmt] return ...
|
||||
# 0| 0: [BooleanLiteral] false
|
||||
# 0| 5: [ReturnStmt] return ...
|
||||
# 0| 0: [BooleanLiteral] true
|
||||
# 1| 7: [Constructor] ProtoMapValue
|
||||
#-----| 4: (Parameters)
|
||||
# 1| 0: [Parameter] bytes
|
||||
# 1| 1: [Parameter] strs
|
||||
# 1| 5: [BlockStmt] { ... }
|
||||
# 1| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 1| 1: [BlockStmt] { ... }
|
||||
# 1| 0: [ExprStmt] <Expr>;
|
||||
# 1| 0: [KtInitializerAssignExpr] ...=...
|
||||
# 1| 0: [VarAccess] bytes
|
||||
# 1| 1: [ExprStmt] <Expr>;
|
||||
# 1| 0: [KtInitializerAssignExpr] ...=...
|
||||
# 1| 0: [VarAccess] strs
|
||||
# 1| 8: [Method] getBytes
|
||||
# 1| 5: [BlockStmt] { ... }
|
||||
# 1| 0: [ReturnStmt] return ...
|
||||
# 1| 0: [VarAccess] this.bytes
|
||||
# 1| -1: [ThisAccess] this
|
||||
# 1| 8: [FieldDeclaration] byte[] bytes;
|
||||
# 1| -1: [TypeAccess] byte[]
|
||||
# 1| 0: [VarAccess] bytes
|
||||
# 1| 10: [Method] getStrs
|
||||
# 1| 5: [BlockStmt] { ... }
|
||||
# 1| 0: [ReturnStmt] return ...
|
||||
# 1| 0: [VarAccess] this.strs
|
||||
# 1| -1: [ThisAccess] this
|
||||
# 1| 10: [FieldDeclaration] String[] strs;
|
||||
# 1| -1: [TypeAccess] String[]
|
||||
# 1| 0: [TypeAccess] String
|
||||
# 1| 0: [VarAccess] strs
|
||||
@@ -0,0 +1 @@
|
||||
semmle/code/java/PrintAst.ql
|
||||
@@ -0,0 +1,8 @@
|
||||
| dc.kt:0:0:0:0 | hashCode(...) | Arrays.hashCode |
|
||||
| dc.kt:0:0:0:0 | hashCode(...) | Arrays.hashCode |
|
||||
| dc.kt:0:0:0:0 | new ProtoMapValue(...) | ProtoMapValue.ProtoMapValue |
|
||||
| dc.kt:0:0:0:0 | plus(...) | Int.plus |
|
||||
| dc.kt:0:0:0:0 | times(...) | Int.times |
|
||||
| dc.kt:0:0:0:0 | toString(...) | Arrays.toString |
|
||||
| dc.kt:0:0:0:0 | toString(...) | Arrays.toString |
|
||||
| dc.kt:1:1:1:71 | super(...) | Any.Any |
|
||||
@@ -0,0 +1,5 @@
|
||||
import java
|
||||
|
||||
from Call c
|
||||
where c.getEnclosingCallable().fromSource()
|
||||
select c, c.getCallee().getQualifiedName()
|
||||
1
java/ql/test/kotlin/library-tests/data-classes/dc.kt
Normal file
1
java/ql/test/kotlin/library-tests/data-classes/dc.kt
Normal file
@@ -0,0 +1 @@
|
||||
data class ProtoMapValue(val bytes: ByteArray, val strs: Array<String>)
|
||||
Reference in New Issue
Block a user