Skip to content

Commit 4095c20

Browse files
committed
C++: Add comments on why 'ReferenceToInstruction' is interpreted like a 'LoadInstruction' at certain places.
1 parent 43a4795 commit 4095c20

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ Operand getSourceAddressOperand(Instruction instr) {
267267
[
268268
instr.(LoadInstruction).getSourceAddressOperand(),
269269
instr.(ReadSideEffectInstruction).getArgumentOperand(),
270+
// `ReferenceToInstruction` is really more of an address-of operation,
271+
// but by including it in this list we break out of `flowOutOfAddressStep` at an
272+
// instruction that, at the source level, looks like a use of a variable.
270273
instr.(ReferenceToInstruction).getSourceAddressOperand()
271274
]
272275
}
@@ -293,6 +296,8 @@ Operand getSourceValueOperand(Instruction instr) {
293296
or
294297
result = instr.(ReadSideEffectInstruction).getSideEffectOperand()
295298
or
299+
// See the comment on the `ReferenceToInstruction` disjunct in `getSourceAddressOperand` for why
300+
// this case is included.
296301
result = instr.(ReferenceToInstruction).getSourceValueOperand()
297302
}
298303

0 commit comments

Comments
 (0)