(Refactor) Make lookThroughImplicitFieldRead public

This commit is contained in:
Owen Mansel-Chan
2025-11-26 10:17:49 +00:00
parent 9bf20702c6
commit dcfa721037
2 changed files with 11 additions and 10 deletions

View File

@@ -1588,4 +1588,9 @@ module IR {
* in a field/method access, element access, or slice expression.
*/
EvalImplicitDerefInstruction implicitDerefInstruction(Expr e) { result = MkImplicitDeref(e) }
/** Gets the base of `insn`, if `insn` is an implicit field read. */
Instruction lookThroughImplicitFieldRead(Instruction insn) {
result = insn.(ImplicitFieldReadInstruction).getBaseInstruction()
}
}

View File

@@ -384,17 +384,13 @@ module SourceSinkInterpretationInput implements
}
private DataFlow::Node skipImplicitFieldReads(DataFlow::Node n) {
not exists(lookThroughImplicitFieldRead(n)) and result = n
not exists(IR::lookThroughImplicitFieldRead(n.asInstruction())) and result = n
or
result = skipImplicitFieldReads(lookThroughImplicitFieldRead(n))
}
private DataFlow::Node lookThroughImplicitFieldRead(DataFlow::Node n) {
result.asInstruction() =
n.(DataFlow::InstructionNode)
.asInstruction()
.(IR::ImplicitFieldReadInstruction)
.getBaseInstruction()
exists(DataFlow::Node mid |
mid.asInstruction() = IR::lookThroughImplicitFieldRead(n.asInstruction())
|
result = skipImplicitFieldReads(mid)
)
}
/** Provides additional sink specification logic. */