Skip to content

2.18.1 Upgrade Fix (DataFlowPrivate libraries) #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,16 @@ class DataFlowCallable extends TDataFlowCallable {
result = this.asSummarizedCallable() or // SummarizedCallable = Function (in CPP)
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
)
}
}

/**
Expand Down Expand Up @@ -1267,6 +1277,15 @@ module IsUnreachableInCall {
string toString() { result = "NodeRegion" }

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) {
Expand Down
19 changes: 19 additions & 0 deletions go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,16 @@ class DataFlowCallable extends TDataFlowCallable {
result = this.asFileScope().getLocation() or
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) {
Expand Down Expand Up @@ -410,6 +420,15 @@ class NodeRegion instanceof BasicBlock {
string toString() { result = "NodeRegion" }

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
)
}
}

/**
Expand Down
39 changes: 39 additions & 0 deletions java/ql/lib/semmle/code/java/dataflow/internal/DataFlowPrivate.qll
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,21 @@ predicate cloneStep(Node n1, Node n2) {
bindingset[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 =
TSrcCallable(Callable c) or
TSummarizedCallable(SummarizedCallable c) or
Expand Down Expand Up @@ -445,10 +460,28 @@ class DataFlowCallable extends TDataFlowCallable {
result = this.asSummarizedCallable().getLocation() or
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;

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 =
TCall(Call c) or
TSummaryCall(SummarizedCallable c, FlowSummaryImpl::Private::SummaryNode receiver) {
Expand Down Expand Up @@ -538,10 +571,16 @@ class SummaryCall extends DataFlowCall, TSummaryCall {
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 {
string toString() { result = "NodeRegion" }

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`. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,16 @@ abstract class DataFlowCallable extends TDataFlowCallable {

/** Gets the location of this dataflow callable. */
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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,8 @@ class NodeRegion instanceof Unit {
string toString() { result = "NodeRegion" }

predicate contains(Node n) { none() }

int totalOrder() { result = 1 }
}

//--------
Expand Down
10 changes: 10 additions & 0 deletions ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowDispatch.qll
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ class DataFlowCallable extends TDataFlowCallable {
this instanceof TLibraryCallable and
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
)
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll
Original file line number Diff line number Diff line change
Expand Up @@ -2183,6 +2183,8 @@ class NodeRegion instanceof Unit {
string toString() { result = "NodeRegion" }

predicate contains(Node n) { none() }

int totalOrder() { result = 1 }
}

/**
Expand Down
5 changes: 5 additions & 0 deletions shared/dataflow/codeql/dataflow/DataFlow.qll
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ signature module InputSig<LocationSig Location> {

/** Gets the location of this callable. */
Location getLocation();

/** Gets a best-effort total ordering. */
int totalorder();
}

class ReturnKind {
Expand Down Expand Up @@ -273,6 +276,8 @@ signature module InputSig<LocationSig Location> {
class NodeRegion {
/** Holds if this region contains `n`. */
predicate contains(Node n);

int totalOrder();
}

/**
Expand Down
10 changes: 10 additions & 0 deletions swift/ql/lib/codeql/swift/dataflow/internal/DataFlowDispatch.qll
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ class DataFlowCallable extends TDataFlowCallable {
Callable::TypeRange getUnderlyingCallable() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,8 @@ class NodeRegion instanceof Unit {
string toString() { result = "NodeRegion" }

predicate contains(Node n) { none() }

int totalOrder() { result = 1 }
}

/**
Expand Down