Skip to content

Commit 98a4096

Browse files
committed
Rust: ignore crate graph elements from summary stats and AST no-location checks
These elements depend on the version of the standard libraries and platform, and in addition no location information is extracted for them at the moment. f
1 parent e21a7f5 commit 98a4096

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ query predicate multipleLocations(Locatable e) { strictcount(e.getLocation()) >
2424
/**
2525
* Holds if `e` does not have a `Location`.
2626
*/
27-
query predicate noLocation(Locatable e) { not exists(e.getLocation()) }
27+
query predicate noLocation(Locatable e) {
28+
not exists(e.getLocation()) and not e.(AstNode).getParentNode*() = any(Crate c).getModule()
29+
}
2830

2931
private predicate multiplePrimaryQlClasses(Element e) {
3032
strictcount(string cls | cls = e.getAPrimaryQlClass() and cls != "VariableAccess") > 1

rust/ql/src/queries/summary/SummaryStats.ql

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ import codeql.rust.Diagnostics
1414
import Stats
1515
import TaintReach
1616

17+
class CrateElement extends Element {
18+
CrateElement() {
19+
this instanceof Crate or
20+
this.(AstNode).getParentNode*() = any(Crate c).getModule()
21+
}
22+
}
23+
1724
from string key, int value
1825
where
19-
key = "Elements extracted" and value = count(Element e | not e instanceof Unextracted)
26+
key = "Elements extracted" and
27+
value = count(Element e | not e instanceof Unextracted and not e instanceof CrateElement)
2028
or
2129
key = "Elements unextracted" and value = count(Unextracted e)
2230
or

0 commit comments

Comments
 (0)