Skip to content

Commit 414fcf8

Browse files
committed
Rust: Move the AST consistency logic to a .qll.
1 parent 79c5adf commit 414fcf8

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed
Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
1-
import rust
2-
import codeql.rust.elements.internal.generated.ParentChild
3-
4-
query predicate multipleToString(Element e, string s) {
5-
s = strictconcat(e.toString(), ",") and
6-
strictcount(e.toString()) > 1
7-
}
8-
9-
query predicate multipleLocations(Locatable e) { strictcount(e.getLocation()) > 1 }
10-
11-
query predicate multiplePrimaryQlClasses(Element e, string s) {
12-
s = e.getPrimaryQlClasses() and
13-
strictcount(e.getAPrimaryQlClass()) > 1
14-
}
15-
16-
private Element getParent(Element child) { child = getChildAndAccessor(result, _, _) }
17-
18-
query predicate multipleParents(Element child, Element parent) {
19-
parent = getParent(child) and
20-
strictcount(getParent(child)) > 1
21-
}
1+
/**
2+
* @name Abstract syntax tree inconsistencies
3+
* @description Lists the abstract syntax tree inconsistencies in the database. This query is intended for internal use.
4+
* @kind table
5+
* @id rust/diagnostics/ast-consistency
6+
*/
7+
8+
import codeql.rust.AstConsistency
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Provides classes for recognizing control flow graph inconsistencies.
3+
*/
4+
5+
private import rust
6+
private import codeql.rust.elements.internal.generated.ParentChild
7+
8+
query predicate multipleToString(Element e, string s) {
9+
s = strictconcat(e.toString(), ",") and
10+
strictcount(e.toString()) > 1
11+
}
12+
13+
query predicate multipleLocations(Locatable e) { strictcount(e.getLocation()) > 1 }
14+
15+
query predicate multiplePrimaryQlClasses(Element e, string s) {
16+
s = e.getPrimaryQlClasses() and
17+
strictcount(e.getAPrimaryQlClass()) > 1
18+
}
19+
20+
private Element getParent(Element child) { child = getChildAndAccessor(result, _, _) }
21+
22+
query predicate multipleParents(Element child, Element parent) {
23+
parent = getParent(child) and
24+
strictcount(getParent(child)) > 1
25+
}

0 commit comments

Comments
 (0)