Skip to content

Commit 77871e2

Browse files
committed
Use RAExpr
1 parent e368b8f commit 77871e2

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ql/ql/src/codeql_ql/StructuredLogs.qll

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
private import ql
22
private import codeql_ql.ast.internal.TreeSitter
3+
private import experimental.RA
34

45
/** Gets a timestamp corresponding to the number of seconds since the date Semmle was founded. */
56
bindingset[d, h, m, s, ms]
@@ -78,6 +79,10 @@ private float getRanked(Array a, int i) {
7879
result = rank[i + 1](int j, float f | f = a.getFloat(j) and f >= 0 | f order by j)
7980
}
8081

82+
private string getRankedLine(Array a, int i) {
83+
result = rank[i + 1](int j, string s | s = a.getString(j) and s != "" | s order by j)
84+
}
85+
8186
module EvaluatorLog {
8287
class Entry extends Object { }
8388

@@ -283,7 +288,9 @@ module KindPredicatesLog {
283288

284289
PipeLine() { this = ra.getArray(raReference) }
285290

286-
string getLineOfRA(int n) { result = this.getString(n) }
291+
string getLineOfRA(int n) { result = getRankedLine(this, n) }
292+
293+
RAExpr getExpr(int n) { result.getPredicate() = this and result.getLine() = n }
287294
}
288295

289296
class RA extends Object {
@@ -320,6 +327,12 @@ module KindPredicatesLog {
320327
raLine = this.getPipeLine().getLineOfRA(pragma[only_bind_into](i))
321328
}
322329

330+
float getCountAndExpr(int i, RAExpr raExpr) {
331+
result = this.getCount(i) and
332+
raExpr.getPredicate() = this.getPipeLine() and
333+
raExpr.getLine() = i
334+
}
335+
323336
float getCount(int i) { result = getRanked(this.getArray("counts"), i) }
324337

325338
float getDuplicationPercentage(int i) {
@@ -376,4 +389,6 @@ module KindPredicatesLog {
376389
class Extensional extends SummaryEvent {
377390
Extensional() { evaluationStrategy = "EXTENSIONAL" }
378391
}
392+
393+
class RAExpr = RAParser<PipeLine>::RAExpr;
379394
}

0 commit comments

Comments
 (0)