Skip to content

Commit 5e2c607

Browse files
committed
PrintAst: reliably sort function overloads
1 parent d3d3ce8 commit 5e2c607

File tree

2 files changed

+164
-159
lines changed

2 files changed

+164
-159
lines changed

java/ql/lib/semmle/code/java/PrintAst.qll

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,12 +534,17 @@ final class ClassInterfaceNode extends ElementNode {
534534
or
535535
childIndex >= 0 and
536536
result.(ElementNode).getElement() =
537-
rank[childIndex](Element e, string file, int line, int column, string childStr |
537+
rank[childIndex](Element e, string file, int line, int column, string childStr, int argCount |
538538
e = this.getADeclaration() and
539539
locationSortKeys(e, file, line, column) and
540-
childStr = e.toString()
540+
childStr = e.toString() and
541+
(
542+
if e instanceof Callable
543+
then argCount = e.(Callable).getNumberOfParameters()
544+
else argCount = 0
545+
)
541546
|
542-
e order by file, line, column, childStr
547+
e order by file, line, column, childStr, argCount
543548
)
544549
}
545550
}

java/ql/test/kotlin/library-tests/exprs/PrintAst.expected

Lines changed: 156 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -3846,58 +3846,6 @@ funcExprs.kt:
38463846
# 36| 5: [BlockStmt] { ... }
38473847
# 36| 0: [SuperConstructorInvocationStmt] super(...)
38483848
# 36| 2: [Method] invoke
3849-
# 36| 3: [TypeAccess] String
3850-
#-----| 4: (Parameters)
3851-
# 36| 0: [Parameter] a0
3852-
# 36| 0: [TypeAccess] int
3853-
# 36| 1: [Parameter] a1
3854-
# 36| 0: [TypeAccess] int
3855-
# 36| 2: [Parameter] a2
3856-
# 36| 0: [TypeAccess] int
3857-
# 36| 3: [Parameter] a3
3858-
# 36| 0: [TypeAccess] int
3859-
# 36| 4: [Parameter] a4
3860-
# 36| 0: [TypeAccess] int
3861-
# 36| 5: [Parameter] a5
3862-
# 36| 0: [TypeAccess] int
3863-
# 36| 6: [Parameter] a6
3864-
# 36| 0: [TypeAccess] int
3865-
# 36| 7: [Parameter] a7
3866-
# 36| 0: [TypeAccess] int
3867-
# 36| 8: [Parameter] a8
3868-
# 36| 0: [TypeAccess] int
3869-
# 36| 9: [Parameter] a9
3870-
# 36| 0: [TypeAccess] int
3871-
# 36| 10: [Parameter] a10
3872-
# 36| 0: [TypeAccess] int
3873-
# 36| 11: [Parameter] a11
3874-
# 36| 0: [TypeAccess] int
3875-
# 36| 12: [Parameter] a12
3876-
# 36| 0: [TypeAccess] int
3877-
# 36| 13: [Parameter] a13
3878-
# 36| 0: [TypeAccess] int
3879-
# 36| 14: [Parameter] a14
3880-
# 36| 0: [TypeAccess] int
3881-
# 36| 15: [Parameter] a15
3882-
# 36| 0: [TypeAccess] int
3883-
# 36| 16: [Parameter] a16
3884-
# 36| 0: [TypeAccess] int
3885-
# 36| 17: [Parameter] a17
3886-
# 36| 0: [TypeAccess] int
3887-
# 36| 18: [Parameter] a18
3888-
# 36| 0: [TypeAccess] int
3889-
# 36| 19: [Parameter] a19
3890-
# 36| 0: [TypeAccess] int
3891-
# 36| 20: [Parameter] a20
3892-
# 36| 0: [TypeAccess] int
3893-
# 36| 21: [Parameter] a21
3894-
# 36| 0: [TypeAccess] int
3895-
# 36| 22: [Parameter] a22
3896-
# 36| 0: [TypeAccess] int
3897-
# 36| 5: [BlockStmt] { ... }
3898-
# 36| 0: [ReturnStmt] return ...
3899-
# 36| 0: [StringLiteral]
3900-
# 36| 2: [Method] invoke
39013849
#-----| 4: (Parameters)
39023850
# 36| 0: [Parameter] a0
39033851
# 36| 5: [BlockStmt] { ... }
@@ -4019,6 +3967,58 @@ funcExprs.kt:
40193967
# 36| 1: [ArrayAccess] ...[...]
40203968
# 36| 0: [VarAccess] a0
40213969
# 36| 1: [IntegerLiteral] 22
3970+
# 36| 3: [Method] invoke
3971+
# 36| 3: [TypeAccess] String
3972+
#-----| 4: (Parameters)
3973+
# 36| 0: [Parameter] a0
3974+
# 36| 0: [TypeAccess] int
3975+
# 36| 1: [Parameter] a1
3976+
# 36| 0: [TypeAccess] int
3977+
# 36| 2: [Parameter] a2
3978+
# 36| 0: [TypeAccess] int
3979+
# 36| 3: [Parameter] a3
3980+
# 36| 0: [TypeAccess] int
3981+
# 36| 4: [Parameter] a4
3982+
# 36| 0: [TypeAccess] int
3983+
# 36| 5: [Parameter] a5
3984+
# 36| 0: [TypeAccess] int
3985+
# 36| 6: [Parameter] a6
3986+
# 36| 0: [TypeAccess] int
3987+
# 36| 7: [Parameter] a7
3988+
# 36| 0: [TypeAccess] int
3989+
# 36| 8: [Parameter] a8
3990+
# 36| 0: [TypeAccess] int
3991+
# 36| 9: [Parameter] a9
3992+
# 36| 0: [TypeAccess] int
3993+
# 36| 10: [Parameter] a10
3994+
# 36| 0: [TypeAccess] int
3995+
# 36| 11: [Parameter] a11
3996+
# 36| 0: [TypeAccess] int
3997+
# 36| 12: [Parameter] a12
3998+
# 36| 0: [TypeAccess] int
3999+
# 36| 13: [Parameter] a13
4000+
# 36| 0: [TypeAccess] int
4001+
# 36| 14: [Parameter] a14
4002+
# 36| 0: [TypeAccess] int
4003+
# 36| 15: [Parameter] a15
4004+
# 36| 0: [TypeAccess] int
4005+
# 36| 16: [Parameter] a16
4006+
# 36| 0: [TypeAccess] int
4007+
# 36| 17: [Parameter] a17
4008+
# 36| 0: [TypeAccess] int
4009+
# 36| 18: [Parameter] a18
4010+
# 36| 0: [TypeAccess] int
4011+
# 36| 19: [Parameter] a19
4012+
# 36| 0: [TypeAccess] int
4013+
# 36| 20: [Parameter] a20
4014+
# 36| 0: [TypeAccess] int
4015+
# 36| 21: [Parameter] a21
4016+
# 36| 0: [TypeAccess] int
4017+
# 36| 22: [Parameter] a22
4018+
# 36| 0: [TypeAccess] int
4019+
# 36| 5: [BlockStmt] { ... }
4020+
# 36| 0: [ReturnStmt] return ...
4021+
# 36| 0: [StringLiteral]
40224022
# 36| -3: [TypeAccess] FunctionN<String>
40234023
# 36| 0: [TypeAccess] String
40244024
# 38| 14: [ExprStmt] <Expr>;
@@ -4683,58 +4683,6 @@ funcExprs.kt:
46834683
# 90| 5: [BlockStmt] { ... }
46844684
# 90| 0: [SuperConstructorInvocationStmt] super(...)
46854685
# 90| 2: [Method] invoke
4686-
# 90| 3: [TypeAccess] String
4687-
#-----| 4: (Parameters)
4688-
# 90| 0: [Parameter] p0
4689-
# 90| 0: [TypeAccess] int
4690-
# 90| 1: [Parameter] p1
4691-
# 90| 0: [TypeAccess] int
4692-
# 90| 2: [Parameter] p2
4693-
# 90| 0: [TypeAccess] int
4694-
# 90| 3: [Parameter] p3
4695-
# 90| 0: [TypeAccess] int
4696-
# 90| 4: [Parameter] p4
4697-
# 90| 0: [TypeAccess] int
4698-
# 90| 5: [Parameter] p5
4699-
# 90| 0: [TypeAccess] int
4700-
# 90| 6: [Parameter] p6
4701-
# 90| 0: [TypeAccess] int
4702-
# 90| 7: [Parameter] p7
4703-
# 90| 0: [TypeAccess] int
4704-
# 90| 8: [Parameter] p8
4705-
# 90| 0: [TypeAccess] int
4706-
# 90| 9: [Parameter] p9
4707-
# 90| 0: [TypeAccess] int
4708-
# 90| 10: [Parameter] p10
4709-
# 90| 0: [TypeAccess] int
4710-
# 90| 11: [Parameter] p11
4711-
# 90| 0: [TypeAccess] int
4712-
# 90| 12: [Parameter] p12
4713-
# 90| 0: [TypeAccess] int
4714-
# 90| 13: [Parameter] p13
4715-
# 90| 0: [TypeAccess] int
4716-
# 90| 14: [Parameter] p14
4717-
# 90| 0: [TypeAccess] int
4718-
# 90| 15: [Parameter] p15
4719-
# 90| 0: [TypeAccess] int
4720-
# 90| 16: [Parameter] p16
4721-
# 90| 0: [TypeAccess] int
4722-
# 90| 17: [Parameter] p17
4723-
# 90| 0: [TypeAccess] int
4724-
# 90| 18: [Parameter] p18
4725-
# 90| 0: [TypeAccess] int
4726-
# 90| 19: [Parameter] p19
4727-
# 90| 0: [TypeAccess] int
4728-
# 90| 20: [Parameter] p20
4729-
# 90| 0: [TypeAccess] int
4730-
# 90| 21: [Parameter] p21
4731-
# 90| 0: [TypeAccess] int
4732-
# 90| 22: [Parameter] p22
4733-
# 90| 0: [TypeAccess] int
4734-
# 90| 5: [BlockStmt] { ... }
4735-
# 90| 0: [ReturnStmt] return ...
4736-
# 90| 0: [StringLiteral]
4737-
# 90| 2: [Method] invoke
47384686
#-----| 4: (Parameters)
47394687
# 90| 0: [Parameter] a0
47404688
# 90| 5: [BlockStmt] { ... }
@@ -4856,6 +4804,58 @@ funcExprs.kt:
48564804
# 90| 1: [ArrayAccess] ...[...]
48574805
# 90| 0: [VarAccess] a0
48584806
# 90| 1: [IntegerLiteral] 22
4807+
# 90| 3: [Method] invoke
4808+
# 90| 3: [TypeAccess] String
4809+
#-----| 4: (Parameters)
4810+
# 90| 0: [Parameter] p0
4811+
# 90| 0: [TypeAccess] int
4812+
# 90| 1: [Parameter] p1
4813+
# 90| 0: [TypeAccess] int
4814+
# 90| 2: [Parameter] p2
4815+
# 90| 0: [TypeAccess] int
4816+
# 90| 3: [Parameter] p3
4817+
# 90| 0: [TypeAccess] int
4818+
# 90| 4: [Parameter] p4
4819+
# 90| 0: [TypeAccess] int
4820+
# 90| 5: [Parameter] p5
4821+
# 90| 0: [TypeAccess] int
4822+
# 90| 6: [Parameter] p6
4823+
# 90| 0: [TypeAccess] int
4824+
# 90| 7: [Parameter] p7
4825+
# 90| 0: [TypeAccess] int
4826+
# 90| 8: [Parameter] p8
4827+
# 90| 0: [TypeAccess] int
4828+
# 90| 9: [Parameter] p9
4829+
# 90| 0: [TypeAccess] int
4830+
# 90| 10: [Parameter] p10
4831+
# 90| 0: [TypeAccess] int
4832+
# 90| 11: [Parameter] p11
4833+
# 90| 0: [TypeAccess] int
4834+
# 90| 12: [Parameter] p12
4835+
# 90| 0: [TypeAccess] int
4836+
# 90| 13: [Parameter] p13
4837+
# 90| 0: [TypeAccess] int
4838+
# 90| 14: [Parameter] p14
4839+
# 90| 0: [TypeAccess] int
4840+
# 90| 15: [Parameter] p15
4841+
# 90| 0: [TypeAccess] int
4842+
# 90| 16: [Parameter] p16
4843+
# 90| 0: [TypeAccess] int
4844+
# 90| 17: [Parameter] p17
4845+
# 90| 0: [TypeAccess] int
4846+
# 90| 18: [Parameter] p18
4847+
# 90| 0: [TypeAccess] int
4848+
# 90| 19: [Parameter] p19
4849+
# 90| 0: [TypeAccess] int
4850+
# 90| 20: [Parameter] p20
4851+
# 90| 0: [TypeAccess] int
4852+
# 90| 21: [Parameter] p21
4853+
# 90| 0: [TypeAccess] int
4854+
# 90| 22: [Parameter] p22
4855+
# 90| 0: [TypeAccess] int
4856+
# 90| 5: [BlockStmt] { ... }
4857+
# 90| 0: [ReturnStmt] return ...
4858+
# 90| 0: [StringLiteral]
48594859
# 90| -3: [TypeAccess] FunctionN<String>
48604860
# 90| 0: [TypeAccess] String
48614861
# 91| 5: [ExprStmt] <Expr>;
@@ -6038,58 +6038,6 @@ samConversion.kt:
60386038
# 43| 5: [BlockStmt] { ... }
60396039
# 43| 0: [SuperConstructorInvocationStmt] super(...)
60406040
# 43| 2: [Method] invoke
6041-
# 43| 3: [TypeAccess] boolean
6042-
#-----| 4: (Parameters)
6043-
# 43| 0: [Parameter] i0
6044-
# 43| 0: [TypeAccess] int
6045-
# 43| 1: [Parameter] i1
6046-
# 43| 0: [TypeAccess] int
6047-
# 43| 2: [Parameter] i2
6048-
# 43| 0: [TypeAccess] int
6049-
# 43| 3: [Parameter] i3
6050-
# 43| 0: [TypeAccess] int
6051-
# 43| 4: [Parameter] i4
6052-
# 43| 0: [TypeAccess] int
6053-
# 43| 5: [Parameter] i5
6054-
# 43| 0: [TypeAccess] int
6055-
# 43| 6: [Parameter] i6
6056-
# 43| 0: [TypeAccess] int
6057-
# 43| 7: [Parameter] i7
6058-
# 43| 0: [TypeAccess] int
6059-
# 43| 8: [Parameter] i8
6060-
# 43| 0: [TypeAccess] int
6061-
# 43| 9: [Parameter] i9
6062-
# 43| 0: [TypeAccess] int
6063-
# 44| 10: [Parameter] i10
6064-
# 44| 0: [TypeAccess] int
6065-
# 44| 11: [Parameter] i11
6066-
# 44| 0: [TypeAccess] int
6067-
# 44| 12: [Parameter] i12
6068-
# 44| 0: [TypeAccess] int
6069-
# 44| 13: [Parameter] i13
6070-
# 44| 0: [TypeAccess] int
6071-
# 44| 14: [Parameter] i14
6072-
# 44| 0: [TypeAccess] int
6073-
# 44| 15: [Parameter] i15
6074-
# 44| 0: [TypeAccess] int
6075-
# 44| 16: [Parameter] i16
6076-
# 44| 0: [TypeAccess] int
6077-
# 44| 17: [Parameter] i17
6078-
# 44| 0: [TypeAccess] int
6079-
# 44| 18: [Parameter] i18
6080-
# 44| 0: [TypeAccess] int
6081-
# 44| 19: [Parameter] i19
6082-
# 44| 0: [TypeAccess] int
6083-
# 45| 20: [Parameter] i20
6084-
# 45| 0: [TypeAccess] int
6085-
# 45| 21: [Parameter] i21
6086-
# 45| 0: [TypeAccess] int
6087-
# 45| 22: [Parameter] i22
6088-
# 45| 0: [TypeAccess] int
6089-
# 45| 5: [BlockStmt] { ... }
6090-
# 45| 0: [ReturnStmt] return ...
6091-
# 45| 0: [BooleanLiteral] true
6092-
# 43| 2: [Method] invoke
60936041
#-----| 4: (Parameters)
60946042
# 43| 0: [Parameter] a0
60956043
# 43| 5: [BlockStmt] { ... }
@@ -6211,6 +6159,58 @@ samConversion.kt:
62116159
# 43| 1: [ArrayAccess] ...[...]
62126160
# 43| 0: [VarAccess] a0
62136161
# 43| 1: [IntegerLiteral] 22
6162+
# 43| 3: [Method] invoke
6163+
# 43| 3: [TypeAccess] boolean
6164+
#-----| 4: (Parameters)
6165+
# 43| 0: [Parameter] i0
6166+
# 43| 0: [TypeAccess] int
6167+
# 43| 1: [Parameter] i1
6168+
# 43| 0: [TypeAccess] int
6169+
# 43| 2: [Parameter] i2
6170+
# 43| 0: [TypeAccess] int
6171+
# 43| 3: [Parameter] i3
6172+
# 43| 0: [TypeAccess] int
6173+
# 43| 4: [Parameter] i4
6174+
# 43| 0: [TypeAccess] int
6175+
# 43| 5: [Parameter] i5
6176+
# 43| 0: [TypeAccess] int
6177+
# 43| 6: [Parameter] i6
6178+
# 43| 0: [TypeAccess] int
6179+
# 43| 7: [Parameter] i7
6180+
# 43| 0: [TypeAccess] int
6181+
# 43| 8: [Parameter] i8
6182+
# 43| 0: [TypeAccess] int
6183+
# 43| 9: [Parameter] i9
6184+
# 43| 0: [TypeAccess] int
6185+
# 44| 10: [Parameter] i10
6186+
# 44| 0: [TypeAccess] int
6187+
# 44| 11: [Parameter] i11
6188+
# 44| 0: [TypeAccess] int
6189+
# 44| 12: [Parameter] i12
6190+
# 44| 0: [TypeAccess] int
6191+
# 44| 13: [Parameter] i13
6192+
# 44| 0: [TypeAccess] int
6193+
# 44| 14: [Parameter] i14
6194+
# 44| 0: [TypeAccess] int
6195+
# 44| 15: [Parameter] i15
6196+
# 44| 0: [TypeAccess] int
6197+
# 44| 16: [Parameter] i16
6198+
# 44| 0: [TypeAccess] int
6199+
# 44| 17: [Parameter] i17
6200+
# 44| 0: [TypeAccess] int
6201+
# 44| 18: [Parameter] i18
6202+
# 44| 0: [TypeAccess] int
6203+
# 44| 19: [Parameter] i19
6204+
# 44| 0: [TypeAccess] int
6205+
# 45| 20: [Parameter] i20
6206+
# 45| 0: [TypeAccess] int
6207+
# 45| 21: [Parameter] i21
6208+
# 45| 0: [TypeAccess] int
6209+
# 45| 22: [Parameter] i22
6210+
# 45| 0: [TypeAccess] int
6211+
# 45| 5: [BlockStmt] { ... }
6212+
# 45| 0: [ReturnStmt] return ...
6213+
# 45| 0: [BooleanLiteral] true
62146214
# 43| -3: [TypeAccess] FunctionN<Boolean>
62156215
# 43| 0: [TypeAccess] Boolean
62166216
# 46| 3: [LocalVariableDeclStmt] var ...;

0 commit comments

Comments
 (0)