mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: Move the AST consistency logic to a .qll.
This commit is contained in:
@@ -1,21 +1,8 @@
|
||||
import rust
|
||||
import codeql.rust.elements.internal.generated.ParentChild
|
||||
/**
|
||||
* @name Abstract syntax tree inconsistencies
|
||||
* @description Lists the abstract syntax tree inconsistencies in the database. This query is intended for internal use.
|
||||
* @kind table
|
||||
* @id rust/diagnostics/ast-consistency
|
||||
*/
|
||||
|
||||
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
|
||||
}
|
||||
import codeql.rust.AstConsistency
|
||||
|
||||
25
rust/ql/lib/codeql/rust/AstConsistency.qll
Normal file
25
rust/ql/lib/codeql/rust/AstConsistency.qll
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Provides classes for recognizing control flow graph inconsistencies.
|
||||
*/
|
||||
|
||||
private import rust
|
||||
private 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
|
||||
}
|
||||
Reference in New Issue
Block a user