@@ -843,7 +843,7 @@ module Array {
843
843
"ArrayElement of Receiver" , "ArrayElement of ArrayElement of Receiver" ,
844
844
"ArrayElement of ArrayElement of ArrayElement of Receiver"
845
845
] and
846
- output = "ArrayElement[?] of Receiver"
846
+ output = [ "ArrayElement[?] of Receiver" , "ArrayElement[?] of ReturnValue" ]
847
847
) and
848
848
preservesValue = true
849
849
}
@@ -1142,6 +1142,25 @@ module Array {
1142
1142
}
1143
1143
}
1144
1144
1145
+ private class RejectBangSummary extends SimpleSummarizedCallable {
1146
+ RejectBangSummary ( ) { this = "reject!" }
1147
+
1148
+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
1149
+ input = "ArrayElement of Receiver" and
1150
+ output =
1151
+ [
1152
+ "ArrayElement[?] of ReturnValue" , "ArrayElement[?] of Receiver" ,
1153
+ "Parameter[0] of BlockArgument"
1154
+ ] and
1155
+ preservesValue = true
1156
+ }
1157
+
1158
+ override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
1159
+ pos .isSelf ( ) and
1160
+ content instanceof DataFlow:: Content:: ArrayElementContent
1161
+ }
1162
+ }
1163
+
1145
1164
private class ReplaceSummary extends SimpleSummarizedCallable {
1146
1165
ReplaceSummary ( ) { this = "replace" }
1147
1166
@@ -1507,14 +1526,6 @@ module Array {
1507
1526
)
1508
1527
)
1509
1528
}
1510
-
1511
- predicate debugDeleteMe ( MethodCall c , string input , string output , int s , int e , int ln ) {
1512
- c = mc and
1513
- s = start and
1514
- e = end and
1515
- propagatesFlowExt ( input , output , _) and
1516
- ln = mc .getLocation ( ) .getStartLine ( )
1517
- }
1518
1529
}
1519
1530
1520
1531
/**
@@ -1548,6 +1559,100 @@ module Array {
1548
1559
}
1549
1560
}
1550
1561
1562
+ private class SortBangSummary extends SimpleSummarizedCallable {
1563
+ SortBangSummary ( ) { this = "sort!" }
1564
+
1565
+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
1566
+ input = "ArrayElement of Receiver" and
1567
+ output =
1568
+ [
1569
+ "Parameter[0] of BlockArgument" , "Parameter[1] of BlockArgument" ,
1570
+ "ArrayElement[?] of Receiver" , "ArrayElement[?] of ReturnValue"
1571
+ ] and
1572
+ preservesValue = true
1573
+ }
1574
+
1575
+ override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
1576
+ pos .isSelf ( ) and
1577
+ content instanceof DataFlow:: Content:: KnownArrayElementContent
1578
+ }
1579
+ }
1580
+
1581
+ private class SortByBangSummary extends SimpleSummarizedCallable {
1582
+ SortByBangSummary ( ) { this = "sort_by!" }
1583
+
1584
+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
1585
+ input = "ArrayElement of Receiver" and
1586
+ output =
1587
+ [
1588
+ "Parameter[0] of BlockArgument" , "ArrayElement[?] of Receiver" ,
1589
+ "ArrayElement[?] of ReturnValue"
1590
+ ] and
1591
+ preservesValue = true
1592
+ }
1593
+
1594
+ override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
1595
+ pos .isSelf ( ) and
1596
+ content instanceof DataFlow:: Content:: KnownArrayElementContent
1597
+ }
1598
+ }
1599
+
1600
+ private class TransposeSummary extends SimpleSummarizedCallable {
1601
+ TransposeSummary ( ) { this = "transpose" }
1602
+
1603
+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
1604
+ preservesValue = true and
1605
+ (
1606
+ input = "ArrayElement[?] of ArrayElement[?] of Receiver" and
1607
+ output = "ArrayElement[?] of ArrayElement[?] of ReturnValue"
1608
+ or
1609
+ exists ( ArrayIndex i , ArrayIndex j |
1610
+ input = "ArrayElement[" + i + "] of ArrayElement[" + j + "] of Receiver" and
1611
+ output = "ArrayElement[" + j + "] of ArrayElement[" + i + "] of ReturnValue"
1612
+ )
1613
+ )
1614
+ }
1615
+ }
1616
+
1617
+ private class UniqBangSummary extends SimpleSummarizedCallable {
1618
+ UniqBangSummary ( ) { this = "uniq!" }
1619
+
1620
+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
1621
+ input = "ArrayElement of Receiver" and
1622
+ output =
1623
+ [
1624
+ "ArrayElement[?] of Receiver" , "ArrayElement[?] of ReturnValue" ,
1625
+ "Parameter[0] of BlockArgument"
1626
+ ] and
1627
+ preservesValue = true
1628
+ }
1629
+
1630
+ override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
1631
+ pos .isSelf ( ) and
1632
+ content instanceof DataFlow:: Content:: KnownArrayElementContent
1633
+ }
1634
+ }
1635
+
1636
+ private class UnionSummary extends SummarizedCallable {
1637
+ MethodCall mc ;
1638
+
1639
+ UnionSummary ( ) { this = "union" and mc .getMethodName ( ) = this }
1640
+
1641
+ override MethodCall getACall ( ) { result = mc }
1642
+
1643
+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
1644
+ (
1645
+ input = "ArrayElement of Receiver"
1646
+ or
1647
+ exists ( int i | i in [ 0 .. mc .getNumberOfArguments ( ) - 1 ] |
1648
+ input = "ArrayElement of Argument[" + i + "]"
1649
+ )
1650
+ ) and
1651
+ output = "ArrayElement[?] of ReturnValue" and
1652
+ preservesValue = true
1653
+ }
1654
+ }
1655
+
1551
1656
abstract private class ValuesAtSummary extends SummarizedCallable {
1552
1657
MethodCall mc ;
1553
1658
@@ -1656,7 +1761,7 @@ module Enumerable {
1656
1761
output = "Parameter[0] of BlockArgument" and
1657
1762
preservesValue = true
1658
1763
or
1659
- input = "ArrayElement of ReturnValue of BlockArgument" and
1764
+ input = [ "ArrayElement of ReturnValue of BlockArgument" , "ReturnValue of BlockArgument" ] and
1660
1765
output = "ArrayElement[?] of ReturnValue" and
1661
1766
preservesValue = true
1662
1767
}
@@ -1997,6 +2102,8 @@ module Enumerable {
1997
2102
or
1998
2103
exists ( ArrayIndex i | i > 0 | input = "ArrayElement[" + i + "] of Receiver" ) and
1999
2104
output = "Parameter[1] of BlockArgument"
2105
+ or
2106
+ input = "ReturnValue of BlockArgument" and output = "ReturnValue"
2000
2107
) and
2001
2108
preservesValue = true
2002
2109
}
@@ -2014,6 +2121,8 @@ module Enumerable {
2014
2121
// Each element in the receiver is passed to the second block parameter.
2015
2122
exists ( ArrayIndex i | input = "ArrayElement[" + i + "] of Receiver" ) and
2016
2123
output = "Parameter[1] of BlockArgument"
2124
+ or
2125
+ input = "ReturnValue of BlockArgument" and output = "ReturnValue"
2017
2126
) and
2018
2127
preservesValue = true
2019
2128
}
@@ -2203,25 +2312,6 @@ module Enumerable {
2203
2312
}
2204
2313
}
2205
2314
2206
- private class RejectBangSummary extends SimpleSummarizedCallable {
2207
- RejectBangSummary ( ) { this = "reject!" }
2208
-
2209
- override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
2210
- input = "ArrayElement of Receiver" and
2211
- output =
2212
- [
2213
- "ArrayElement[?] of ReturnValue" , "ArrayElement[?] of Receiver" ,
2214
- "Parameter[0] of BlockArgument"
2215
- ] and
2216
- preservesValue = true
2217
- }
2218
-
2219
- override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
2220
- pos .isSelf ( ) and
2221
- content instanceof DataFlow:: Content:: ArrayElementContent
2222
- }
2223
- }
2224
-
2225
2315
private class SelectSummary extends SimpleSummarizedCallable {
2226
2316
// `find_all` and `filter` are aliases of `select`.
2227
2317
SelectSummary ( ) { this = [ "select" , "find_all" , "filter" ] }
@@ -2267,25 +2357,6 @@ module Enumerable {
2267
2357
}
2268
2358
}
2269
2359
2270
- private class SortBangSummary extends SimpleSummarizedCallable {
2271
- SortBangSummary ( ) { this = "sort!" }
2272
-
2273
- override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
2274
- input = "ArrayElement of Receiver" and
2275
- output =
2276
- [
2277
- "Parameter[0] of BlockArgument" , "Parameter[1] of BlockArgument" ,
2278
- "ArrayElement[?] of Receiver" , "ArrayElement[?] of ReturnValue"
2279
- ] and
2280
- preservesValue = true
2281
- }
2282
-
2283
- override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
2284
- pos .isSelf ( ) and
2285
- content instanceof DataFlow:: Content:: KnownArrayElementContent
2286
- }
2287
- }
2288
-
2289
2360
private class SortBySummary extends SimpleSummarizedCallable {
2290
2361
SortBySummary ( ) { this = "sort_by" }
2291
2362
@@ -2296,25 +2367,6 @@ module Enumerable {
2296
2367
}
2297
2368
}
2298
2369
2299
- private class SortByBangSummary extends SimpleSummarizedCallable {
2300
- SortByBangSummary ( ) { this = "sort_by!" }
2301
-
2302
- override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
2303
- input = "ArrayElement of Receiver" and
2304
- output =
2305
- [
2306
- "Parameter[0] of BlockArgument" , "ArrayElement[?] of Receiver" ,
2307
- "ArrayElement[?] of ReturnValue"
2308
- ] and
2309
- preservesValue = true
2310
- }
2311
-
2312
- override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
2313
- pos .isSelf ( ) and
2314
- content instanceof DataFlow:: Content:: KnownArrayElementContent
2315
- }
2316
- }
2317
-
2318
2370
private class SumSummary extends SimpleSummarizedCallable {
2319
2371
SumSummary ( ) { this = "sum" }
2320
2372
@@ -2377,7 +2429,7 @@ module Enumerable {
2377
2429
2378
2430
override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
2379
2431
input = "ArrayElement of Receiver" and
2380
- output = [ "Parameter[0] of BlockArgument" ] and
2432
+ output = "Parameter[0] of BlockArgument" and
2381
2433
preservesValue = true
2382
2434
or
2383
2435
// We can't know the size of the return value, but we know that indices
@@ -2401,43 +2453,6 @@ module Enumerable {
2401
2453
}
2402
2454
}
2403
2455
2404
- private class TransposeSummary extends SimpleSummarizedCallable {
2405
- TransposeSummary ( ) { this = "transpose" }
2406
-
2407
- override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
2408
- preservesValue = true and
2409
- (
2410
- input = "ArrayElement[?] of ArrayElement[?] of Receiver" and
2411
- output = "ArrayElement[?] of ArrayElement[?] of ReturnValue"
2412
- or
2413
- exists ( ArrayIndex i , ArrayIndex j |
2414
- input = "ArrayElement[" + i + "] of ArrayElement[" + j + "] of Receiver" and
2415
- output = "ArrayElement[" + j + "] of ArrayElement[" + i + "] of ReturnValue"
2416
- )
2417
- )
2418
- }
2419
- }
2420
-
2421
- private class UnionSummary extends SummarizedCallable {
2422
- MethodCall mc ;
2423
-
2424
- UnionSummary ( ) { this = "union" and mc .getMethodName ( ) = this }
2425
-
2426
- override MethodCall getACall ( ) { result = mc }
2427
-
2428
- override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
2429
- (
2430
- input = "ArrayElement of Receiver"
2431
- or
2432
- exists ( int i | i in [ 0 .. mc .getNumberOfArguments ( ) - 1 ] |
2433
- input = "ArrayElement of Argument[" + i + "]"
2434
- )
2435
- ) and
2436
- output = "ArrayElement[?] of ReturnValue" and
2437
- preservesValue = true
2438
- }
2439
- }
2440
-
2441
2456
private class UniqSummary extends SimpleSummarizedCallable {
2442
2457
UniqSummary ( ) { this = "uniq" }
2443
2458
@@ -2448,25 +2463,6 @@ module Enumerable {
2448
2463
}
2449
2464
}
2450
2465
2451
- private class UniqBangSummary extends SimpleSummarizedCallable {
2452
- UniqBangSummary ( ) { this = "uniq!" }
2453
-
2454
- override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
2455
- input = "ArrayElement of Receiver" and
2456
- output =
2457
- [
2458
- "ArrayElement[?] of Receiver" , "ArrayElement[?] of ReturnValue" ,
2459
- "Parameter[0] of BlockArgument"
2460
- ] and
2461
- preservesValue = true
2462
- }
2463
-
2464
- override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
2465
- pos .isSelf ( ) and
2466
- content instanceof DataFlow:: Content:: KnownArrayElementContent
2467
- }
2468
- }
2469
-
2470
2466
abstract private class ZipSummary extends SummarizedCallable {
2471
2467
MethodCall mc ;
2472
2468
@@ -2504,7 +2500,7 @@ module Enumerable {
2504
2500
output = "ArrayElement[0] of ArrayElement[" + i + "] of ReturnValue"
2505
2501
)
2506
2502
or
2507
- // receiver[?] -> return_value[0][? ]
2503
+ // receiver[?] -> return_value[?][0 ]
2508
2504
input = "ArrayElement[?] of Receiver" and
2509
2505
output = "ArrayElement[0] of ArrayElement[?] of ReturnValue"
2510
2506
or
0 commit comments