Skip to content

Commit 36d8a6d

Browse files
author
Paolo Tranquilli
committed
Rust: add class printouts to AstConsistency.ql
1 parent d8b453f commit 36d8a6d

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

rust/ql/consistency-queries/DataFlowConsistency.ql

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,3 @@ private import codeql.dataflow.internal.DataFlowImplConsistency
1414
private module Input implements InputSig<Location, RustDataFlow> { }
1515

1616
import MakeConsistency<Location, RustDataFlow, RustTaintTracking, Input>
17-
18-
/**
19-
* This adds `AstNode` class names to the results of `uniqueNodeToString`, if any.
20-
*/
21-
query predicate uniqueNodeToStringClasses(Node n, string cls) {
22-
uniqueNodeToString(n, _) and
23-
cls = n.getCfgNode().getAstNode().getPrimaryQlClasses()
24-
}

rust/ql/lib/codeql/rust/AstConsistency.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ private predicate multipleToStrings(Element e) { strictcount(e.toString()) > 1 }
1010
/**
1111
* Holds if `e` has more than one `toString()` result.
1212
*/
13-
query predicate multipleToStrings(Element e, string s) {
13+
query predicate multipleToStrings(Element e, string cls, string s) {
1414
multipleToStrings(e) and
15+
cls = e.getPrimaryQlClasses() and
1516
s = strictconcat(e.toString(), ", ")
1617
}
1718

@@ -39,9 +40,11 @@ private predicate multipleParents(Element child) { strictcount(getParent(child))
3940
/**
4041
* Holds if `child` has more than one AST parent.
4142
*/
42-
query predicate multipleParents(Element child, Element parent) {
43+
query predicate multipleParents(Element child, string childClass, Element parent, string parentClass) {
4344
multipleParents(child) and
44-
parent = getParent(child)
45+
childClass = child.getPrimaryQlClasses() and
46+
parent = getParent(child) and
47+
parentClass = parent.getPrimaryQlClasses()
4548
}
4649

4750
/**

0 commit comments

Comments
 (0)