@@ -3208,9 +3208,20 @@ class TranslatedBuiltInOperation extends TranslatedNonConstantExpr {
32083208
32093209 final override Instruction getResult ( ) { result = this .getInstruction ( OnlyInstructionTag ( ) ) }
32103210
3211+ /**
3212+ * Gets the rnk'th (0-indexed) child for which a `TranslatedElement` exists.
3213+ *
3214+ * We use this predicate to filter out `TypeName` expressions that sometimes
3215+ * occur in builtin operations since the IR doesn't have an instruction to
3216+ * represent a reference to a type.
3217+ */
3218+ private TranslatedElement getRankedChild ( int rnk ) {
3219+ result = rank [ rnk + 1 ] ( int id , TranslatedElement te | te = this .getChild ( id ) | te order by id )
3220+ }
3221+
32113222 final override Instruction getFirstInstruction ( EdgeKind kind ) {
3212- if exists ( this .getChild ( 0 ) )
3213- then result = this .getChild ( 0 ) .getFirstInstruction ( kind )
3223+ if exists ( this .getRankedChild ( 0 ) )
3224+ then result = this .getRankedChild ( 0 ) .getFirstInstruction ( kind )
32143225 else (
32153226 kind instanceof GotoEdge and result = this .getInstruction ( OnlyInstructionTag ( ) )
32163227 )
@@ -3230,11 +3241,11 @@ class TranslatedBuiltInOperation extends TranslatedNonConstantExpr {
32303241 }
32313242
32323243 final override Instruction getChildSuccessorInternal ( TranslatedElement child , EdgeKind kind ) {
3233- exists ( int id | child = this .getChild ( id ) |
3234- result = this .getChild ( id + 1 ) .getFirstInstruction ( kind )
3244+ exists ( int id | child = this .getRankedChild ( id ) |
3245+ result = this .getRankedChild ( id + 1 ) .getFirstInstruction ( kind )
32353246 or
32363247 kind instanceof GotoEdge and
3237- not exists ( this .getChild ( id + 1 ) ) and
3248+ not exists ( this .getRankedChild ( id + 1 ) ) and
32383249 result = this .getInstruction ( OnlyInstructionTag ( ) )
32393250 )
32403251 }
@@ -3249,7 +3260,7 @@ class TranslatedBuiltInOperation extends TranslatedNonConstantExpr {
32493260 tag = OnlyInstructionTag ( ) and
32503261 exists ( int index |
32513262 operandTag = positionalArgumentOperand ( index ) and
3252- result = this .getChild ( index ) .( TranslatedExpr ) .getResult ( )
3263+ result = this .getRankedChild ( index ) .( TranslatedExpr ) .getResult ( )
32533264 )
32543265 }
32553266
0 commit comments