Skip to content

Commit dcfa721

Browse files
committed
(Refactor) Make lookThroughImplicitFieldRead public
1 parent 9bf2070 commit dcfa721

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

go/ql/lib/semmle/go/controlflow/IR.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,4 +1588,9 @@ module IR {
15881588
* in a field/method access, element access, or slice expression.
15891589
*/
15901590
EvalImplicitDerefInstruction implicitDerefInstruction(Expr e) { result = MkImplicitDeref(e) }
1591+
1592+
/** Gets the base of `insn`, if `insn` is an implicit field read. */
1593+
Instruction lookThroughImplicitFieldRead(Instruction insn) {
1594+
result = insn.(ImplicitFieldReadInstruction).getBaseInstruction()
1595+
}
15911596
}

go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,17 +384,13 @@ module SourceSinkInterpretationInput implements
384384
}
385385

386386
private DataFlow::Node skipImplicitFieldReads(DataFlow::Node n) {
387-
not exists(lookThroughImplicitFieldRead(n)) and result = n
387+
not exists(IR::lookThroughImplicitFieldRead(n.asInstruction())) and result = n
388388
or
389-
result = skipImplicitFieldReads(lookThroughImplicitFieldRead(n))
390-
}
391-
392-
private DataFlow::Node lookThroughImplicitFieldRead(DataFlow::Node n) {
393-
result.asInstruction() =
394-
n.(DataFlow::InstructionNode)
395-
.asInstruction()
396-
.(IR::ImplicitFieldReadInstruction)
397-
.getBaseInstruction()
389+
exists(DataFlow::Node mid |
390+
mid.asInstruction() = IR::lookThroughImplicitFieldRead(n.asInstruction())
391+
|
392+
result = skipImplicitFieldReads(mid)
393+
)
398394
}
399395

400396
/** Provides additional sink specification logic. */

0 commit comments

Comments
 (0)