Skip to content

Commit da5abc8

Browse files
committed
Dataflow: Replace MakeSets with QlBuiltins::InternSets.
1 parent a951718 commit da5abc8

File tree

15 files changed

+41
-407
lines changed

15 files changed

+41
-407
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,7 @@ class CastNode extends Node {
239239
CastNode() { none() } // stub implementation
240240
}
241241

242-
class DataFlowCallable extends Function {
243-
/** Gets a best-effort total ordering. */
244-
int totalorder() {
245-
this =
246-
rank[result](DataFlowCallable c, string file, int startline, int startcolumn |
247-
c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _)
248-
|
249-
c order by file, startline, startcolumn
250-
)
251-
}
252-
}
242+
class DataFlowCallable extends Function { }
253243

254244
class DataFlowExpr = Expr;
255245

@@ -269,24 +259,12 @@ class DataFlowCall extends Expr instanceof Call {
269259

270260
/** Gets the enclosing callable of this call. */
271261
DataFlowCallable getEnclosingCallable() { result = this.getEnclosingFunction() }
272-
273-
/** Gets a best-effort total ordering. */
274-
int totalorder() {
275-
this =
276-
rank[result](DataFlowCall c, int startline, int startcolumn |
277-
c.getLocation().hasLocationInfo(_, startline, startcolumn, _, _)
278-
|
279-
c order by startline, startcolumn
280-
)
281-
}
282262
}
283263

284264
class NodeRegion instanceof Unit {
285265
string toString() { result = "NodeRegion" }
286266

287267
predicate contains(Node n) { none() }
288-
289-
int totalOrder() { result = 1 }
290268
}
291269

292270
predicate isUnreachableInCall(NodeRegion nr, DataFlowCall call) { none() } // stub implementation

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,16 +1060,6 @@ class DataFlowCallable extends TDataFlowCallable {
10601060
result = this.asSummarizedCallable() or // SummarizedCallable = Function (in CPP)
10611061
result = this.asSourceCallable()
10621062
}
1063-
1064-
/** Gets a best-effort total ordering. */
1065-
int totalorder() {
1066-
this =
1067-
rank[result](DataFlowCallable c, string file, int startline, int startcolumn |
1068-
c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _)
1069-
|
1070-
c order by file, startline, startcolumn
1071-
)
1072-
}
10731063
}
10741064

10751065
/**
@@ -1167,16 +1157,6 @@ class DataFlowCall extends TDataFlowCall {
11671157
* Gets the location of this call.
11681158
*/
11691159
Location getLocation() { none() }
1170-
1171-
/** Gets a best-effort total ordering. */
1172-
int totalorder() {
1173-
this =
1174-
rank[result](DataFlowCall c, int startline, int startcolumn |
1175-
c.getLocation().hasLocationInfo(_, startline, startcolumn, _, _)
1176-
|
1177-
c order by startline, startcolumn
1178-
)
1179-
}
11801160
}
11811161

11821162
/**
@@ -1269,15 +1249,6 @@ module IsUnreachableInCall {
12691249
string toString() { result = "NodeRegion" }
12701250

12711251
predicate contains(Node n) { this = n.getBasicBlock() }
1272-
1273-
int totalOrder() {
1274-
this =
1275-
rank[result](IRBlock b, int startline, int startcolumn |
1276-
b.getLocation().hasLocationInfo(_, startline, startcolumn, _, _)
1277-
|
1278-
b order by startline, startcolumn
1279-
)
1280-
}
12811252
}
12821253

12831254
predicate isUnreachableInCall(NodeRegion block, DataFlowCall call) {

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowDispatch.qll

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,6 @@ class DataFlowCallable extends TDataFlowCallable {
191191
or
192192
result = this.asCapturedVariable().getLocation()
193193
}
194-
195-
/** Gets a best-effort total ordering. */
196-
int totalorder() {
197-
this =
198-
rank[result](DataFlowCallable c, string file, int startline, int startcolumn |
199-
c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _)
200-
|
201-
c order by file, startline, startcolumn
202-
)
203-
}
204194
}
205195

206196
/** A call relevant for data flow. */
@@ -244,16 +234,6 @@ abstract class DataFlowCall extends TDataFlowCall {
244234
) {
245235
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
246236
}
247-
248-
/** Gets a best-effort total ordering. */
249-
int totalorder() {
250-
this =
251-
rank[result](DataFlowCall c, int startline, int startcolumn |
252-
c.hasLocationInfo(_, startline, startcolumn, _, _)
253-
|
254-
c order by startline, startcolumn
255-
)
256-
}
257237
}
258238

259239
/** A non-delegate C# call relevant for data flow. */

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,15 +2379,6 @@ class NodeRegion instanceof ControlFlow::BasicBlock {
23792379
string toString() { result = "NodeRegion" }
23802380

23812381
predicate contains(Node n) { this = n.getControlFlowNode().getBasicBlock() }
2382-
2383-
int totalOrder() {
2384-
this =
2385-
rank[result](ControlFlow::BasicBlock b, int startline, int startcolumn |
2386-
b.getLocation().hasLocationInfo(_, startline, startcolumn, _, _)
2387-
|
2388-
b order by startline, startcolumn
2389-
)
2390-
}
23912382
}
23922383

23932384
/**

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

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,6 @@ class DataFlowCallable extends TDataFlowCallable {
318318
result = this.asFileScope().getLocation() or
319319
result = getCallableLocation(this.asSummarizedCallable())
320320
}
321-
322-
/** Gets a best-effort total ordering. */
323-
int totalorder() {
324-
this =
325-
rank[result](DataFlowCallable c, string file, int startline, int startcolumn |
326-
c.hasLocationInfo(file, startline, startcolumn, _, _)
327-
|
328-
c order by file, startline, startcolumn
329-
)
330-
}
331321
}
332322

333323
private Location getCallableLocation(Callable c) {
@@ -361,16 +351,6 @@ class DataFlowCall extends Expr {
361351

362352
/** Gets the location of this call. */
363353
Location getLocation() { result = super.getLocation() }
364-
365-
/** Gets a best-effort total ordering. */
366-
int totalorder() {
367-
this =
368-
rank[result](DataFlowCall c, int startline, int startcolumn |
369-
c.getLocation().hasLocationInfo(_, startline, startcolumn, _, _)
370-
|
371-
c order by startline, startcolumn
372-
)
373-
}
374354
}
375355

376356
/** Holds if `e` is an expression that always has the same Boolean value `val`. */
@@ -413,15 +393,6 @@ class NodeRegion instanceof BasicBlock {
413393
string toString() { result = "NodeRegion" }
414394

415395
predicate contains(Node n) { n.getBasicBlock() = this }
416-
417-
int totalOrder() {
418-
this =
419-
rank[result](BasicBlock b, int startline, int startcolumn |
420-
b.hasLocationInfo(_, startline, startcolumn, _, _)
421-
|
422-
b order by startline, startcolumn
423-
)
424-
}
425396
}
426397

427398
/**

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowPrivate.qll

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -400,21 +400,6 @@ class CastNode extends ExprNode {
400400
}
401401
}
402402

403-
private predicate id_member(Member x, Member y) { x = y }
404-
405-
private predicate idOf_member(Member x, int y) = equivalenceRelation(id_member/2)(x, y)
406-
407-
private int summarizedCallableId(SummarizedCallable c) {
408-
c =
409-
rank[result](SummarizedCallable c0, int b, int i, string s |
410-
b = 0 and idOf_member(c0.asCallable(), i) and s = ""
411-
or
412-
b = 1 and i = 0 and s = c0.asSyntheticCallable()
413-
|
414-
c0 order by b, i, s
415-
)
416-
}
417-
418403
private newtype TDataFlowCallable =
419404
TSrcCallable(Callable c) or
420405
TSummarizedCallable(SummarizedCallable c) or
@@ -448,28 +433,10 @@ class DataFlowCallable extends TDataFlowCallable {
448433
result = this.asSummarizedCallable().getLocation() or
449434
result = this.asFieldScope().getLocation()
450435
}
451-
452-
/** Gets a best-effort total ordering. */
453-
int totalorder() {
454-
this =
455-
rank[result](DataFlowCallable c, int b, int i |
456-
b = 0 and idOf_member(c.asCallable(), i)
457-
or
458-
b = 1 and i = summarizedCallableId(c.asSummarizedCallable())
459-
or
460-
b = 2 and idOf_member(c.asFieldScope(), i)
461-
|
462-
c order by b, i
463-
)
464-
}
465436
}
466437

467438
class DataFlowExpr = Expr;
468439

469-
private predicate id_call(Call x, Call y) { x = y }
470-
471-
private predicate idOf_call(Call x, int y) = equivalenceRelation(id_call/2)(x, y)
472-
473440
private newtype TDataFlowCall =
474441
TCall(Call c) or
475442
TSummaryCall(SummarizedCallable c, FlowSummaryImpl::Private::SummaryNode receiver) {
@@ -502,19 +469,6 @@ class DataFlowCall extends TDataFlowCall {
502469
) {
503470
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
504471
}
505-
506-
/** Gets a best-effort total ordering. */
507-
int totalorder() {
508-
this =
509-
rank[result](DataFlowCall c, int b, int i |
510-
b = 0 and idOf_call(c.asCall(), i)
511-
or
512-
b = 1 and // not guaranteed to be total
513-
exists(SummarizedCallable sc | c = TSummaryCall(sc, _) and i = summarizedCallableId(sc))
514-
|
515-
c order by b, i
516-
)
517-
}
518472
}
519473

520474
/** A source call, that is, a `Call`. */
@@ -549,16 +503,10 @@ class SummaryCall extends DataFlowCall, TSummaryCall {
549503
override Location getLocation() { result = c.getLocation() }
550504
}
551505

552-
private predicate id(BasicBlock x, BasicBlock y) { x = y }
553-
554-
private predicate idOf(BasicBlock x, int y) = equivalenceRelation(id/2)(x, y)
555-
556506
class NodeRegion instanceof BasicBlock {
557507
string toString() { result = "NodeRegion" }
558508

559509
predicate contains(Node n) { n.asExpr().getBasicBlock() = this }
560-
561-
int totalOrder() { idOf(this, result) }
562510
}
563511

564512
/** Holds if `e` is an expression that always has the same Boolean value `val`. */

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -344,16 +344,6 @@ abstract class DataFlowCallable extends TDataFlowCallable {
344344

345345
/** Gets the location of this dataflow callable. */
346346
abstract Location getLocation();
347-
348-
/** Gets a best-effort total ordering. */
349-
int totalorder() {
350-
this =
351-
rank[result](DataFlowCallable c, string file, int startline, int startcolumn |
352-
c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _)
353-
|
354-
c order by file, startline, startcolumn
355-
)
356-
}
357347
}
358348

359349
/** A callable function. */
@@ -1435,16 +1425,6 @@ abstract class DataFlowCall extends TDataFlowCall {
14351425
) {
14361426
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
14371427
}
1438-
1439-
/** Gets a best-effort total ordering. */
1440-
int totalorder() {
1441-
this =
1442-
rank[result](DataFlowCall c, int startline, int startcolumn |
1443-
c.hasLocationInfo(_, startline, startcolumn, _, _)
1444-
|
1445-
c order by startline, startcolumn
1446-
)
1447-
}
14481428
}
14491429

14501430
/** A call found in the program source (as opposed to a synthesised call). */

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,8 +1025,6 @@ class NodeRegion instanceof Unit {
10251025
string toString() { result = "NodeRegion" }
10261026

10271027
predicate contains(Node n) { none() }
1028-
1029-
int totalOrder() { result = 1 }
10301028
}
10311029

10321030
//--------

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowDispatch.qll

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,6 @@ class DataFlowCallable extends TDataFlowCallable {
113113
this instanceof TLibraryCallable and
114114
result instanceof EmptyLocation
115115
}
116-
117-
/** Gets a best-effort total ordering. */
118-
int totalorder() {
119-
this =
120-
rank[result](DataFlowCallable c, string file, int startline, int startcolumn |
121-
c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _)
122-
|
123-
c order by file, startline, startcolumn
124-
)
125-
}
126116
}
127117

128118
/**
@@ -154,16 +144,6 @@ abstract class DataFlowCall extends TDataFlowCall {
154144
) {
155145
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
156146
}
157-
158-
/** Gets a best-effort total ordering. */
159-
int totalorder() {
160-
this =
161-
rank[result](DataFlowCall c, int startline, int startcolumn |
162-
c.hasLocationInfo(_, startline, startcolumn, _, _)
163-
|
164-
c order by startline, startcolumn
165-
)
166-
}
167147
}
168148

169149
/**

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,8 +2183,6 @@ class NodeRegion instanceof Unit {
21832183
string toString() { result = "NodeRegion" }
21842184

21852185
predicate contains(Node n) { none() }
2186-
2187-
int totalOrder() { result = 1 }
21882186
}
21892187

21902188
/**

0 commit comments

Comments
 (0)