Skip to content

Commit 56cabb8

Browse files
committed
C++: Add comments to some of the disjuncts in 'addressFlow'.
1 parent 092beb8 commit 56cabb8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternals.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,16 @@ predicate addressFlow(Instruction iFrom, Instruction iTo) {
215215
or
216216
iTo.(FieldAddressInstruction).getObjectAddress() = iFrom
217217
or
218+
// We traverse `LoadInstruction`s since we want to conclude that the
219+
// destination of the store operation `*x = source()` is derived from `x`.
218220
iTo.(LoadInstruction).getSourceAddress() = iFrom
219221
or
222+
// We want to include `ReadSideEffectInstruction`s for the same reason that we include
223+
// `LoadInstruction`s, but only when a `WriteSideEffectInstruction` for the same index exists as well
224+
// (as otherwise we know that the callee won't override the data). However, given an index `i`, the
225+
// destination of the `WriteSideEffectInstruction` for `i` is identical to the source address of the
226+
// `ReadSideEffectInstruction` for `i`. So we don't have to talk about the `ReadSideEffectInstruction`
227+
// at all.
220228
exists(WriteSideEffectInstruction write |
221229
write.getPrimaryInstruction() = iTo and
222230
write.getDestinationAddress() = iFrom

0 commit comments

Comments
 (0)