Skip to content

Commit 24517e3

Browse files
authored
Merge pull request #77 from microsoft/dilan/2.18.1-upgrade-2
2.18.1 Upgrade Fix (DataFlowPrivate libraries)
2 parents be7fce5 + ed8ada3 commit 24517e3

File tree

10 files changed

+118
-0
lines changed

10 files changed

+118
-0
lines changed

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

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

10661076
/**
@@ -1267,6 +1277,15 @@ module IsUnreachableInCall {
12671277
string toString() { result = "NodeRegion" }
12681278

12691279
predicate contains(Node n) { this = n.getBasicBlock() }
1280+
1281+
int totalOrder() {
1282+
this =
1283+
rank[result](IRBlock b, int startline, int startcolumn |
1284+
b.getLocation().hasLocationInfo(_, startline, startcolumn, _, _)
1285+
|
1286+
b order by startline, startcolumn
1287+
)
1288+
}
12701289
}
12711290

12721291
predicate isUnreachableInCall(NodeRegion block, DataFlowCall call) {

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,16 @@ 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+
}
321331
}
322332

323333
private Location getCallableLocation(Callable c) {
@@ -410,6 +420,15 @@ class NodeRegion instanceof BasicBlock {
410420
string toString() { result = "NodeRegion" }
411421

412422
predicate contains(Node n) { n.getBasicBlock() = this }
423+
424+
int totalOrder() {
425+
this =
426+
rank[result](BasicBlock b, int startline, int startcolumn |
427+
b.hasLocationInfo(_, startline, startcolumn, _, _)
428+
|
429+
b order by startline, startcolumn
430+
)
431+
}
413432
}
414433

415434
/**

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,21 @@ predicate cloneStep(Node n1, Node n2) {
412412
bindingset[node1, node2]
413413
predicate validParameterAliasStep(Node node1, Node node2) { not cloneStep(node1, node2) }
414414

415+
private predicate id_member(Member x, Member y) { x = y }
416+
417+
private predicate idOf_member(Member x, int y) = equivalenceRelation(id_member/2)(x, y)
418+
419+
private int summarizedCallableId(SummarizedCallable c) {
420+
c =
421+
rank[result](SummarizedCallable c0, int b, int i, string s |
422+
b = 0 and idOf_member(c0.asCallable(), i) and s = ""
423+
or
424+
b = 1 and i = 0 and s = c0.asSyntheticCallable()
425+
|
426+
c0 order by b, i, s
427+
)
428+
}
429+
415430
private newtype TDataFlowCallable =
416431
TSrcCallable(Callable c) or
417432
TSummarizedCallable(SummarizedCallable c) or
@@ -445,10 +460,28 @@ class DataFlowCallable extends TDataFlowCallable {
445460
result = this.asSummarizedCallable().getLocation() or
446461
result = this.asFieldScope().getLocation()
447462
}
463+
464+
/** Gets a best-effort total ordering. */
465+
int totalorder() {
466+
this =
467+
rank[result](DataFlowCallable c, int b, int i |
468+
b = 0 and idOf_member(c.asCallable(), i)
469+
or
470+
b = 1 and i = summarizedCallableId(c.asSummarizedCallable())
471+
or
472+
b = 2 and idOf_member(c.asFieldScope(), i)
473+
|
474+
c order by b, i
475+
)
476+
}
448477
}
449478

450479
class DataFlowExpr = Expr;
451480

481+
private predicate id_call(Call x, Call y) { x = y }
482+
483+
private predicate idOf_call(Call x, int y) = equivalenceRelation(id_call/2)(x, y)
484+
452485
private newtype TDataFlowCall =
453486
TCall(Call c) or
454487
TSummaryCall(SummarizedCallable c, FlowSummaryImpl::Private::SummaryNode receiver) {
@@ -538,10 +571,16 @@ class SummaryCall extends DataFlowCall, TSummaryCall {
538571
override Location getLocation() { result = c.getLocation() }
539572
}
540573

574+
private predicate id(BasicBlock x, BasicBlock y) { x = y }
575+
576+
private predicate idOf(BasicBlock x, int y) = equivalenceRelation(id/2)(x, y)
577+
541578
class NodeRegion instanceof BasicBlock {
542579
string toString() { result = "NodeRegion" }
543580

544581
predicate contains(Node n) { n.asExpr().getBasicBlock() = this }
582+
583+
int totalOrder() { idOf(this, result) }
545584
}
546585

547586
/** 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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,16 @@ 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+
}
347357
}
348358

349359
/** A callable function. */

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

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

10271027
predicate contains(Node n) { none() }
1028+
1029+
int totalOrder() { result = 1 }
10281030
}
10291031

10301032
//--------

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ 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+
}
116126
}
117127

118128
/**

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

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

21852185
predicate contains(Node n) { none() }
2186+
2187+
int totalOrder() { result = 1 }
21862188
}
21872189

21882190
/**

shared/dataflow/codeql/dataflow/DataFlow.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ signature module InputSig<LocationSig Location> {
9797

9898
/** Gets the location of this callable. */
9999
Location getLocation();
100+
101+
/** Gets a best-effort total ordering. */
102+
int totalorder();
100103
}
101104

102105
class ReturnKind {
@@ -273,6 +276,8 @@ signature module InputSig<LocationSig Location> {
273276
class NodeRegion {
274277
/** Holds if this region contains `n`. */
275278
predicate contains(Node n);
279+
280+
int totalOrder();
276281
}
277282

278283
/**

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ class DataFlowCallable extends TDataFlowCallable {
6565
Callable::TypeRange getUnderlyingCallable() {
6666
result = this.asSummarizedCallable() or result = this.asSourceCallable()
6767
}
68+
69+
/** Gets a best-effort total ordering. */
70+
int totalorder() {
71+
this =
72+
rank[result](DataFlowCallable c, string file, int startline, int startcolumn |
73+
c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _)
74+
|
75+
c order by file, startline, startcolumn
76+
)
77+
}
6878
}
6979

7080
cached

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

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

13831383
predicate contains(Node n) { none() }
1384+
1385+
int totalOrder() { result = 1 }
13841386
}
13851387

13861388
/**

0 commit comments

Comments
 (0)