@@ -208,7 +208,7 @@ private module IteratorIndirections {
208
208
209
209
override predicate isAdditionalDereference ( Instruction deref , Operand address ) {
210
210
exists ( CallInstruction call |
211
- operandForfullyConvertedCall ( deref . getAUse ( ) , call ) and
211
+ operandForfullyConvertedCall ( getAUse ( deref ) , call ) and
212
212
this = call .getStaticCallTarget ( ) .getClassAndName ( "operator*" ) and
213
213
address = call .getThisArgumentOperand ( )
214
214
)
@@ -585,6 +585,15 @@ private module Cached {
585
585
)
586
586
}
587
587
588
+ /** Holds if `op` is the only use of its defining instruction, and that op is used in a conversation */
589
+ private predicate isConversion ( Operand op ) {
590
+ exists ( Instruction def , Operand use |
591
+ def = op .getDef ( ) and
592
+ use = unique( | | getAUse ( def ) ) and
593
+ conversionFlow ( use , _, false , false )
594
+ )
595
+ }
596
+
588
597
/**
589
598
* Holds if `op` is a use of an SSA variable rooted at `base` with `ind` number
590
599
* of indirections.
@@ -602,6 +611,9 @@ private module Cached {
602
611
type = getLanguageType ( op ) and
603
612
upper = countIndirectionsForCppType ( type ) and
604
613
isUseImpl ( op , base , ind0 ) and
614
+ // Don't count every conversion as their own use. Instead, only the first
615
+ // use (i.e., before any conversions are applied) will count as a use.
616
+ not isConversion ( op ) and
605
617
ind = ind0 + [ 0 .. upper ] and
606
618
indirectionIndex = ind - ind0
607
619
)
0 commit comments