@@ -274,7 +274,7 @@ class Node extends TIRDataFlowNode {
274274 * represents the value of `**x` going into `f`.
275275 */
276276 Expr asIndirectArgument ( int index ) {
277- this .( SideEffectOperandNode ) .getIndirectionIndex ( ) = index and
277+ this .( SideEffectOperandNode ) .hasAddressOperandAndIndirectionIndex ( _ , index ) and
278278 result = this .( SideEffectOperandNode ) .getArgument ( )
279279 }
280280
@@ -317,7 +317,7 @@ class Node extends TIRDataFlowNode {
317317 index = 0 and
318318 result = this .( ExplicitParameterNode ) .getParameter ( )
319319 or
320- this .( IndirectParameterNode ) .getIndirectionIndex ( ) = index and
320+ this .( IndirectParameterNode ) .hasInstructionAndIndirectionIndex ( _ , index ) and
321321 result = this .( IndirectParameterNode ) .getParameter ( )
322322 }
323323
@@ -577,15 +577,20 @@ class SsaPhiNode extends Node, TSsaPhiNode {
577577 *
578578 * A node representing a value after leaving a function.
579579 */
580- class SideEffectOperandNode extends Node , IndirectOperand {
580+ class SideEffectOperandNode extends Node instanceof IndirectOperand {
581581 CallInstruction call ;
582582 int argumentIndex ;
583583
584- SideEffectOperandNode ( ) { operand = call .getArgumentOperand ( argumentIndex ) }
584+ SideEffectOperandNode ( ) {
585+ IndirectOperand .super .hasOperandAndIndirectionIndex ( call .getArgumentOperand ( argumentIndex ) , _)
586+ }
585587
586588 CallInstruction getCallInstruction ( ) { result = call }
587589
588- Operand getAddressOperand ( ) { result = operand }
590+ /** Gets the underlying operand and the underlying indirection index. */
591+ predicate hasAddressOperandAndIndirectionIndex ( Operand operand , int indirectionIndex ) {
592+ IndirectOperand .super .hasOperandAndIndirectionIndex ( operand , indirectionIndex )
593+ }
589594
590595 int getArgumentIndex ( ) { result = argumentIndex }
591596
@@ -665,10 +670,10 @@ class InitialGlobalValue extends Node, TInitialGlobalValue {
665670 *
666671 * A node representing an indirection of a parameter.
667672 */
668- class IndirectParameterNode extends Node , IndirectInstruction {
673+ class IndirectParameterNode extends Node instanceof IndirectInstruction {
669674 InitializeParameterInstruction init ;
670675
671- IndirectParameterNode ( ) { this . getInstruction ( ) = init }
676+ IndirectParameterNode ( ) { IndirectInstruction . super . hasInstructionAndIndirectionIndex ( init , _ ) }
672677
673678 int getArgumentIndex ( ) { init .hasIndex ( result ) }
674679
@@ -677,7 +682,12 @@ class IndirectParameterNode extends Node, IndirectInstruction {
677682
678683 override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
679684
680- override Declaration getFunction ( ) { result = this .getInstruction ( ) .getEnclosingFunction ( ) }
685+ override Declaration getFunction ( ) { result = init .getEnclosingFunction ( ) }
686+
687+ /** Gets the underlying operand and the underlying indirection index. */
688+ predicate hasInstructionAndIndirectionIndex ( Instruction instr , int index ) {
689+ IndirectInstruction .super .hasInstructionAndIndirectionIndex ( instr , index )
690+ }
681691
682692 override Location getLocationImpl ( ) { result = this .getParameter ( ) .getLocation ( ) }
683693
@@ -699,7 +709,8 @@ class IndirectReturnNode extends Node {
699709 IndirectReturnNode ( ) {
700710 this instanceof FinalParameterNode
701711 or
702- this .( IndirectOperand ) .getOperand ( ) = any ( ReturnValueInstruction ret ) .getReturnAddressOperand ( )
712+ this .( IndirectOperand )
713+ .hasOperandAndIndirectionIndex ( any ( ReturnValueInstruction ret ) .getReturnAddressOperand ( ) , _)
703714 }
704715
705716 override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
@@ -722,7 +733,7 @@ class IndirectReturnNode extends Node {
722733 int getIndirectionIndex ( ) {
723734 result = this .( FinalParameterNode ) .getIndirectionIndex ( )
724735 or
725- result = this .( IndirectOperand ) .getIndirectionIndex ( )
736+ this .( IndirectOperand ) .hasOperandAndIndirectionIndex ( _ , result )
726737 }
727738}
728739
@@ -1106,7 +1117,8 @@ predicate exprNodeShouldBeInstruction(Node node, Expr e) {
11061117/** Holds if `node` should be an `IndirectInstruction` that maps `node.asIndirectExpr()` to `e`. */
11071118predicate indirectExprNodeShouldBeIndirectInstruction ( IndirectInstruction node , Expr e ) {
11081119 exists ( Instruction instr |
1109- instr = node .getInstruction ( ) and not indirectExprNodeShouldBeIndirectOperand ( _, e )
1120+ node .hasInstructionAndIndirectionIndex ( instr , _) and
1121+ not indirectExprNodeShouldBeIndirectOperand ( _, e )
11101122 |
11111123 e = instr .( VariableAddressInstruction ) .getAst ( ) .( Expr ) .getFullyConverted ( )
11121124 or
@@ -1307,8 +1319,8 @@ pragma[noinline]
13071319private predicate indirectParameterNodeHasArgumentIndexAndIndex (
13081320 IndirectParameterNode node , int argumentIndex , int indirectionIndex
13091321) {
1310- node .getArgumentIndex ( ) = argumentIndex and
1311- node .getIndirectionIndex ( ) = indirectionIndex
1322+ node .hasInstructionAndIndirectionIndex ( _ , indirectionIndex ) and
1323+ node .getArgumentIndex ( ) = argumentIndex
13121324}
13131325
13141326/** A synthetic parameter to model the pointed-to object of a pointer parameter. */
@@ -1479,18 +1491,14 @@ VariableNode variableNode(Variable v) {
14791491 */
14801492Node uninitializedNode ( LocalVariable v ) { none ( ) }
14811493
1482- pragma [ noinline]
14831494predicate hasOperandAndIndex ( IndirectOperand indirectOperand , Operand operand , int indirectionIndex ) {
1484- indirectOperand .getOperand ( ) = operand and
1485- indirectOperand .getIndirectionIndex ( ) = indirectionIndex
1495+ indirectOperand .hasOperandAndIndirectionIndex ( operand , indirectionIndex )
14861496}
14871497
1488- pragma [ noinline]
14891498predicate hasInstructionAndIndex (
14901499 IndirectInstruction indirectInstr , Instruction instr , int indirectionIndex
14911500) {
1492- indirectInstr .getInstruction ( ) = instr and
1493- indirectInstr .getIndirectionIndex ( ) = indirectionIndex
1501+ indirectInstr .hasInstructionAndIndirectionIndex ( instr , indirectionIndex )
14941502}
14951503
14961504cached
@@ -1656,8 +1664,7 @@ module ExprFlowCached {
16561664 private predicate isIndirectBaseOfArrayAccess ( IndirectOperand n , Expr e ) {
16571665 exists ( LoadInstruction load , PointerArithmeticInstruction pai |
16581666 pai = load .getSourceAddress ( ) and
1659- pai .getLeftOperand ( ) = n .getOperand ( ) and
1660- n .getIndirectionIndex ( ) = 1 and
1667+ n .hasOperandAndIndirectionIndex ( pai .getLeftOperand ( ) , 1 ) and
16611668 e = load .getConvertedResultExpression ( )
16621669 )
16631670 }
0 commit comments