Skip to content

Commit

Permalink
Merge pull request github#17690 from hvitved/rust/ast-consistency-que…
Browse files Browse the repository at this point in the history
…ries

Rust: Add AST consistency queries
  • Loading branch information
hvitved authored Oct 9, 2024
2 parents 04d1c82 + 08d6d54 commit 918e435
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions rust/ql/consistency-queries/AstConsistency.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import rust
import codeql.rust.elements.internal.generated.ParentChild

query predicate multipleToString(Element e, string s) {
s = strictconcat(e.toString(), ",") and
strictcount(e.toString()) > 1
}

query predicate multipleLocations(Locatable e) { strictcount(e.getLocation()) > 1 }

query predicate multiplePrimaryQlClasses(Element e, string s) {
s = e.getPrimaryQlClasses() and
strictcount(e.getAPrimaryQlClass()) > 1
}

private Element getParent(Element child) { child = getChildAndAccessor(result, _, _) }

query predicate multipleParents(Element child, Element parent) {
parent = getParent(child) and
strictcount(getParent(child)) > 1
}

0 comments on commit 918e435

Please sign in to comment.