mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Rust: Refactor flow summary implementation
This commit is contained in:
@@ -11,6 +11,20 @@ private import codeql.rust.dataflow.FlowSummary
|
|||||||
private import codeql.rust.dataflow.Ssa
|
private import codeql.rust.dataflow.Ssa
|
||||||
private import Content
|
private import Content
|
||||||
|
|
||||||
|
predicate encodeContentTupleField(TupleFieldContent c, string arg) {
|
||||||
|
exists(Addressable a, int pos, string prefix |
|
||||||
|
arg = prefix + "(" + pos + ")" and prefix = a.getCanonicalPath()
|
||||||
|
|
|
||||||
|
c.isStructField(a, pos) or c.isVariantField(a, pos)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
predicate encodeContentStructField(StructFieldContent c, string arg) {
|
||||||
|
exists(Addressable a, string field | arg = a.getCanonicalPath() + "::" + field |
|
||||||
|
c.isStructField(a, field) or c.isVariantField(a, field)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
module Input implements InputSig<Location, RustDataFlow> {
|
module Input implements InputSig<Location, RustDataFlow> {
|
||||||
private import codeql.rust.frameworks.stdlib.Stdlib
|
private import codeql.rust.frameworks.stdlib.Stdlib
|
||||||
|
|
||||||
@@ -58,24 +72,11 @@ module Input implements InputSig<Location, RustDataFlow> {
|
|||||||
exists(Content c | cs = TSingletonContentSet(c) |
|
exists(Content c | cs = TSingletonContentSet(c) |
|
||||||
result = "Field" and
|
result = "Field" and
|
||||||
(
|
(
|
||||||
exists(Addressable a, int pos, string prefix |
|
encodeContentTupleField(c, arg)
|
||||||
arg = prefix + "(" + pos + ")" and prefix = a.getCanonicalPath()
|
|
||||||
|
|
|
||||||
c.(TupleFieldContent).isStructField(a, pos)
|
|
||||||
or
|
or
|
||||||
c.(TupleFieldContent).isVariantField(a, pos)
|
encodeContentStructField(c, arg)
|
||||||
)
|
|
||||||
or
|
or
|
||||||
exists(Addressable a, string field | arg = a.getCanonicalPath() + "::" + field |
|
exists(int pos | c = TTuplePositionContent(pos) and arg = pos.toString())
|
||||||
c.(StructFieldContent).isStructField(a, field)
|
|
||||||
or
|
|
||||||
c.(StructFieldContent).isVariantField(a, field)
|
|
||||||
)
|
|
||||||
or
|
|
||||||
exists(int pos |
|
|
||||||
c = TTuplePositionContent(pos) and
|
|
||||||
arg = pos.toString()
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
or
|
or
|
||||||
result = "Reference" and
|
result = "Reference" and
|
||||||
|
|||||||
Reference in New Issue
Block a user