apply Mathias patch

This commit is contained in:
Dilan Bhalla
2024-08-02 15:44:52 -07:00
parent 73ee8ef664
commit ed8ada30e8
10 changed files with 118 additions and 0 deletions

View File

@@ -1061,6 +1061,16 @@ class DataFlowCallable extends TDataFlowCallable {
result = this.asSummarizedCallable() or // SummarizedCallable = Function (in CPP) result = this.asSummarizedCallable() or // SummarizedCallable = Function (in CPP)
result = this.asSourceCallable() result = this.asSourceCallable()
} }
/** Gets a best-effort total ordering. */
int totalorder() {
this =
rank[result](DataFlowCallable c, string file, int startline, int startcolumn |
c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _)
|
c order by file, startline, startcolumn
)
}
} }
/** /**
@@ -1267,6 +1277,15 @@ module IsUnreachableInCall {
string toString() { result = "NodeRegion" } string toString() { result = "NodeRegion" }
predicate contains(Node n) { this = n.getBasicBlock() } predicate contains(Node n) { this = n.getBasicBlock() }
int totalOrder() {
this =
rank[result](IRBlock b, int startline, int startcolumn |
b.getLocation().hasLocationInfo(_, startline, startcolumn, _, _)
|
b order by startline, startcolumn
)
}
} }
predicate isUnreachableInCall(NodeRegion block, DataFlowCall call) { predicate isUnreachableInCall(NodeRegion block, DataFlowCall call) {

View File

@@ -318,6 +318,16 @@ class DataFlowCallable extends TDataFlowCallable {
result = this.asFileScope().getLocation() or result = this.asFileScope().getLocation() or
result = getCallableLocation(this.asSummarizedCallable()) result = getCallableLocation(this.asSummarizedCallable())
} }
/** Gets a best-effort total ordering. */
int totalorder() {
this =
rank[result](DataFlowCallable c, string file, int startline, int startcolumn |
c.hasLocationInfo(file, startline, startcolumn, _, _)
|
c order by file, startline, startcolumn
)
}
} }
private Location getCallableLocation(Callable c) { private Location getCallableLocation(Callable c) {
@@ -410,6 +420,15 @@ class NodeRegion instanceof BasicBlock {
string toString() { result = "NodeRegion" } string toString() { result = "NodeRegion" }
predicate contains(Node n) { n.getBasicBlock() = this } predicate contains(Node n) { n.getBasicBlock() = this }
int totalOrder() {
this =
rank[result](BasicBlock b, int startline, int startcolumn |
b.hasLocationInfo(_, startline, startcolumn, _, _)
|
b order by startline, startcolumn
)
}
} }
/** /**

View File

@@ -412,6 +412,21 @@ predicate cloneStep(Node n1, Node n2) {
bindingset[node1, node2] bindingset[node1, node2]
predicate validParameterAliasStep(Node node1, Node node2) { not cloneStep(node1, node2) } predicate validParameterAliasStep(Node node1, Node node2) { not cloneStep(node1, node2) }
private predicate id_member(Member x, Member y) { x = y }
private predicate idOf_member(Member x, int y) = equivalenceRelation(id_member/2)(x, y)
private int summarizedCallableId(SummarizedCallable c) {
c =
rank[result](SummarizedCallable c0, int b, int i, string s |
b = 0 and idOf_member(c0.asCallable(), i) and s = ""
or
b = 1 and i = 0 and s = c0.asSyntheticCallable()
|
c0 order by b, i, s
)
}
private newtype TDataFlowCallable = private newtype TDataFlowCallable =
TSrcCallable(Callable c) or TSrcCallable(Callable c) or
TSummarizedCallable(SummarizedCallable c) or TSummarizedCallable(SummarizedCallable c) or
@@ -445,10 +460,28 @@ class DataFlowCallable extends TDataFlowCallable {
result = this.asSummarizedCallable().getLocation() or result = this.asSummarizedCallable().getLocation() or
result = this.asFieldScope().getLocation() result = this.asFieldScope().getLocation()
} }
/** Gets a best-effort total ordering. */
int totalorder() {
this =
rank[result](DataFlowCallable c, int b, int i |
b = 0 and idOf_member(c.asCallable(), i)
or
b = 1 and i = summarizedCallableId(c.asSummarizedCallable())
or
b = 2 and idOf_member(c.asFieldScope(), i)
|
c order by b, i
)
}
} }
class DataFlowExpr = Expr; class DataFlowExpr = Expr;
private predicate id_call(Call x, Call y) { x = y }
private predicate idOf_call(Call x, int y) = equivalenceRelation(id_call/2)(x, y)
private newtype TDataFlowCall = private newtype TDataFlowCall =
TCall(Call c) or TCall(Call c) or
TSummaryCall(SummarizedCallable c, FlowSummaryImpl::Private::SummaryNode receiver) { TSummaryCall(SummarizedCallable c, FlowSummaryImpl::Private::SummaryNode receiver) {
@@ -538,10 +571,16 @@ class SummaryCall extends DataFlowCall, TSummaryCall {
override Location getLocation() { result = c.getLocation() } override Location getLocation() { result = c.getLocation() }
} }
private predicate id(BasicBlock x, BasicBlock y) { x = y }
private predicate idOf(BasicBlock x, int y) = equivalenceRelation(id/2)(x, y)
class NodeRegion instanceof BasicBlock { class NodeRegion instanceof BasicBlock {
string toString() { result = "NodeRegion" } string toString() { result = "NodeRegion" }
predicate contains(Node n) { n.asExpr().getBasicBlock() = this } predicate contains(Node n) { n.asExpr().getBasicBlock() = this }
int totalOrder() { idOf(this, result) }
} }
/** Holds if `e` is an expression that always has the same Boolean value `val`. */ /** Holds if `e` is an expression that always has the same Boolean value `val`. */

View File

@@ -344,6 +344,16 @@ abstract class DataFlowCallable extends TDataFlowCallable {
/** Gets the location of this dataflow callable. */ /** Gets the location of this dataflow callable. */
abstract Location getLocation(); abstract Location getLocation();
/** Gets a best-effort total ordering. */
int totalorder() {
this =
rank[result](DataFlowCallable c, string file, int startline, int startcolumn |
c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _)
|
c order by file, startline, startcolumn
)
}
} }
/** A callable function. */ /** A callable function. */

View File

@@ -1025,6 +1025,8 @@ class NodeRegion instanceof Unit {
string toString() { result = "NodeRegion" } string toString() { result = "NodeRegion" }
predicate contains(Node n) { none() } predicate contains(Node n) { none() }
int totalOrder() { result = 1 }
} }
//-------- //--------

View File

@@ -113,6 +113,16 @@ class DataFlowCallable extends TDataFlowCallable {
this instanceof TLibraryCallable and this instanceof TLibraryCallable and
result instanceof EmptyLocation result instanceof EmptyLocation
} }
/** Gets a best-effort total ordering. */
int totalorder() {
this =
rank[result](DataFlowCallable c, string file, int startline, int startcolumn |
c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _)
|
c order by file, startline, startcolumn
)
}
} }
/** /**

View File

@@ -2183,6 +2183,8 @@ class NodeRegion instanceof Unit {
string toString() { result = "NodeRegion" } string toString() { result = "NodeRegion" }
predicate contains(Node n) { none() } predicate contains(Node n) { none() }
int totalOrder() { result = 1 }
} }
/** /**

View File

@@ -97,6 +97,9 @@ signature module InputSig<LocationSig Location> {
/** Gets the location of this callable. */ /** Gets the location of this callable. */
Location getLocation(); Location getLocation();
/** Gets a best-effort total ordering. */
int totalorder();
} }
class ReturnKind { class ReturnKind {
@@ -273,6 +276,8 @@ signature module InputSig<LocationSig Location> {
class NodeRegion { class NodeRegion {
/** Holds if this region contains `n`. */ /** Holds if this region contains `n`. */
predicate contains(Node n); predicate contains(Node n);
int totalOrder();
} }
/** /**

View File

@@ -65,6 +65,16 @@ class DataFlowCallable extends TDataFlowCallable {
Callable::TypeRange getUnderlyingCallable() { Callable::TypeRange getUnderlyingCallable() {
result = this.asSummarizedCallable() or result = this.asSourceCallable() result = this.asSummarizedCallable() or result = this.asSourceCallable()
} }
/** Gets a best-effort total ordering. */
int totalorder() {
this =
rank[result](DataFlowCallable c, string file, int startline, int startcolumn |
c.getLocation().hasLocationInfo(file, startline, startcolumn, _, _)
|
c order by file, startline, startcolumn
)
}
} }
cached cached

View File

@@ -1381,6 +1381,8 @@ class NodeRegion instanceof Unit {
string toString() { result = "NodeRegion" } string toString() { result = "NodeRegion" }
predicate contains(Node n) { none() } predicate contains(Node n) { none() }
int totalOrder() { result = 1 }
} }
/** /**