@@ -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,19 @@ 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+ predicate hasAddressOperandAndIndirectionIndex ( Operand operand , int indirectionIndex ) {
591+ IndirectOperand .super .hasOperandAndIndirectionIndex ( operand , indirectionIndex )
592+ }
589593
590594 int getArgumentIndex ( ) { result = argumentIndex }
591595
@@ -665,10 +669,10 @@ class InitialGlobalValue extends Node, TInitialGlobalValue {
665669 *
666670 * A node representing an indirection of a parameter.
667671 */
668- class IndirectParameterNode extends Node , IndirectInstruction {
672+ class IndirectParameterNode extends Node instanceof IndirectInstruction {
669673 InitializeParameterInstruction init ;
670674
671- IndirectParameterNode ( ) { this . getInstruction ( ) = init }
675+ IndirectParameterNode ( ) { IndirectInstruction . super . hasInstructionAndIndirectionIndex ( init , _ ) }
672676
673677 int getArgumentIndex ( ) { init .hasIndex ( result ) }
674678
@@ -677,7 +681,12 @@ class IndirectParameterNode extends Node, IndirectInstruction {
677681
678682 override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
679683
680- override Declaration getFunction ( ) { result = this .getInstruction ( ) .getEnclosingFunction ( ) }
684+ override Declaration getFunction ( ) { result = init .getEnclosingFunction ( ) }
685+
686+ /** Gets the underlying instruction. */
687+ predicate hasInstructionAndIndirectionIndex ( Instruction instr , int index ) {
688+ IndirectInstruction .super .hasInstructionAndIndirectionIndex ( instr , index )
689+ }
681690
682691 override Location getLocationImpl ( ) { result = this .getParameter ( ) .getLocation ( ) }
683692
@@ -699,7 +708,8 @@ class IndirectReturnNode extends Node {
699708 IndirectReturnNode ( ) {
700709 this instanceof FinalParameterNode
701710 or
702- this .( IndirectOperand ) .getOperand ( ) = any ( ReturnValueInstruction ret ) .getReturnAddressOperand ( )
711+ this .( IndirectOperand )
712+ .hasOperandAndIndirectionIndex ( any ( ReturnValueInstruction ret ) .getReturnAddressOperand ( ) , _)
703713 }
704714
705715 override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
@@ -722,7 +732,7 @@ class IndirectReturnNode extends Node {
722732 int getIndirectionIndex ( ) {
723733 result = this .( FinalParameterNode ) .getIndirectionIndex ( )
724734 or
725- result = this .( IndirectOperand ) .getIndirectionIndex ( )
735+ this .( IndirectOperand ) .hasOperandAndIndirectionIndex ( _ , result )
726736 }
727737}
728738
@@ -1106,7 +1116,8 @@ predicate exprNodeShouldBeInstruction(Node node, Expr e) {
11061116/** Holds if `node` should be an `IndirectInstruction` that maps `node.asIndirectExpr()` to `e`. */
11071117predicate indirectExprNodeShouldBeIndirectInstruction ( IndirectInstruction node , Expr e ) {
11081118 exists ( Instruction instr |
1109- instr = node .getInstruction ( ) and not indirectExprNodeShouldBeIndirectOperand ( _, e )
1119+ node .hasInstructionAndIndirectionIndex ( instr , _) and
1120+ not indirectExprNodeShouldBeIndirectOperand ( _, e )
11101121 |
11111122 e = instr .( VariableAddressInstruction ) .getAst ( ) .( Expr ) .getFullyConverted ( )
11121123 or
@@ -1307,8 +1318,8 @@ pragma[noinline]
13071318private predicate indirectParameterNodeHasArgumentIndexAndIndex (
13081319 IndirectParameterNode node , int argumentIndex , int indirectionIndex
13091320) {
1310- node .getArgumentIndex ( ) = argumentIndex and
1311- node .getIndirectionIndex ( ) = indirectionIndex
1321+ node .hasInstructionAndIndirectionIndex ( _ , indirectionIndex ) and
1322+ node .getArgumentIndex ( ) = argumentIndex
13121323}
13131324
13141325/** A synthetic parameter to model the pointed-to object of a pointer parameter. */
@@ -1479,18 +1490,14 @@ VariableNode variableNode(Variable v) {
14791490 */
14801491Node uninitializedNode ( LocalVariable v ) { none ( ) }
14811492
1482- pragma [ noinline]
14831493predicate hasOperandAndIndex ( IndirectOperand indirectOperand , Operand operand , int indirectionIndex ) {
1484- indirectOperand .getOperand ( ) = operand and
1485- indirectOperand .getIndirectionIndex ( ) = indirectionIndex
1494+ indirectOperand .hasOperandAndIndirectionIndex ( operand , indirectionIndex )
14861495}
14871496
1488- pragma [ noinline]
14891497predicate hasInstructionAndIndex (
14901498 IndirectInstruction indirectInstr , Instruction instr , int indirectionIndex
14911499) {
1492- indirectInstr .getInstruction ( ) = instr and
1493- indirectInstr .getIndirectionIndex ( ) = indirectionIndex
1500+ indirectInstr .hasInstructionAndIndirectionIndex ( instr , indirectionIndex )
14941501}
14951502
14961503cached
@@ -1656,8 +1663,7 @@ module ExprFlowCached {
16561663 private predicate isIndirectBaseOfArrayAccess ( IndirectOperand n , Expr e ) {
16571664 exists ( LoadInstruction load , PointerArithmeticInstruction pai |
16581665 pai = load .getSourceAddress ( ) and
1659- pai .getLeftOperand ( ) = n .getOperand ( ) and
1660- n .getIndirectionIndex ( ) = 1 and
1666+ n .hasOperandAndIndirectionIndex ( pai .getLeftOperand ( ) , 1 ) and
16611667 e = load .getConvertedResultExpression ( )
16621668 )
16631669 }
0 commit comments