@@ -463,6 +463,7 @@ cached
463463private module Cached {
464464 private import semmle.code.cpp.models.interfaces.Iterator as Interfaces
465465 private import semmle.code.cpp.models.implementations.Iterator as Iterator
466+ private import semmle.code.cpp.models.interfaces.FunctionInputsAndOutputs as IO
466467
467468 /**
468469 * Holds if `next` is a instruction with a memory result that potentially
@@ -593,11 +594,16 @@ private module Cached {
593594 private predicate isChiAfterBegin (
594595 BaseSourceVariableInstruction containerBase , StoreInstruction iterator
595596 ) {
596- exists ( CallInstruction getIterator |
597+ exists (
598+ CallInstruction getIterator , Iterator:: GetIteratorFunction getIteratorFunction ,
599+ IO:: FunctionInput input , int i
600+ |
597601 getIterator = iterator .getSourceValue ( ) and
598- getIterator .getStaticCallTarget ( ) instanceof Iterator:: GetIteratorFunction and
602+ getIteratorFunction = getIterator .getStaticCallTarget ( ) and
603+ getIteratorFunction .getsIterator ( input , _) and
599604 isDef ( _, any ( Node0Impl n | n .asInstruction ( ) = iterator ) , _, _, 1 , 0 ) and
600- isUse ( _, getIterator .getThisArgumentOperand ( ) , containerBase , 0 , 0 )
605+ input .isParameterDerefOrQualifierObject ( i ) and
606+ isUse ( _, getIterator .getArgumentOperand ( i ) , containerBase , 0 , 0 )
601607 )
602608 }
603609
0 commit comments