File tree Expand file tree Collapse file tree
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -217,6 +217,16 @@ private module IteratorIndirections {
217217 )
218218 }
219219
220+ // A by-value crement result loads the iterator, rather than aliasing its address.
221+ override predicate isAdditionalDereference ( Instruction deref , Operand address ) {
222+ exists ( CallInstruction call |
223+ deref = call and
224+ call .getStaticCallTarget ( ) instanceof Iterator:: IteratorCrementMemberOperator and
225+ not call .getResultType ( ) instanceof Cpp:: ReferenceType and
226+ address = call .getThisArgumentOperand ( )
227+ )
228+ }
229+
220230 override predicate isAdditionalConversionFlow ( Operand opFrom , Instruction instrTo ) {
221231 // This is a bit annoying: Consider the following snippet:
222232 // ```
@@ -255,11 +265,11 @@ private module IteratorIndirections {
255265 store .getDestinationAddress ( ) = var
256266 )
257267 or
258- // A call to `operator++` or `operator--` is the iterator equivalent version of a
259- // pointer arithmetic instruction.
268+ // A reference-returning `operator++` or `operator--` preserves the iterator's address.
260269 exists ( CallInstruction call |
261270 instrTo = call and
262271 call .getStaticCallTarget ( ) instanceof Iterator:: IteratorCrementMemberOperator and
272+ call .getResultType ( ) instanceof Cpp:: ReferenceType and
263273 opFrom = call .getThisArgumentOperand ( )
264274 )
265275 }
You can’t perform that action at this time.
0 commit comments