@@ -274,7 +274,7 @@ class Node extends TIRDataFlowNode {
274
274
* represents the value of `**x` going into `f`.
275
275
*/
276
276
Expr asIndirectArgument ( int index ) {
277
- this .( SideEffectOperandNode ) .getIndirectionIndex ( ) = index and
277
+ this .( SideEffectOperandNode ) .hasAddressOperandAndIndirectionIndex ( _ , index ) and
278
278
result = this .( SideEffectOperandNode ) .getArgument ( )
279
279
}
280
280
@@ -317,7 +317,7 @@ class Node extends TIRDataFlowNode {
317
317
index = 0 and
318
318
result = this .( ExplicitParameterNode ) .getParameter ( )
319
319
or
320
- this .( IndirectParameterNode ) .getIndirectionIndex ( ) = index and
320
+ this .( IndirectParameterNode ) .hasInstructionAndIndirectionIndex ( _ , index ) and
321
321
result = this .( IndirectParameterNode ) .getParameter ( )
322
322
}
323
323
@@ -577,15 +577,19 @@ class SsaPhiNode extends Node, TSsaPhiNode {
577
577
*
578
578
* A node representing a value after leaving a function.
579
579
*/
580
- class SideEffectOperandNode extends Node , IndirectOperand {
580
+ class SideEffectOperandNode extends Node instanceof IndirectOperand {
581
581
CallInstruction call ;
582
582
int argumentIndex ;
583
583
584
- SideEffectOperandNode ( ) { operand = call .getArgumentOperand ( argumentIndex ) }
584
+ SideEffectOperandNode ( ) {
585
+ IndirectOperand .super .hasOperandAndIndirectionIndex ( call .getArgumentOperand ( argumentIndex ) , _)
586
+ }
585
587
586
588
CallInstruction getCallInstruction ( ) { result = call }
587
589
588
- Operand getAddressOperand ( ) { result = operand }
590
+ predicate hasAddressOperandAndIndirectionIndex ( Operand operand , int indirectionIndex ) {
591
+ IndirectOperand .super .hasOperandAndIndirectionIndex ( operand , indirectionIndex )
592
+ }
589
593
590
594
int getArgumentIndex ( ) { result = argumentIndex }
591
595
@@ -665,10 +669,10 @@ class InitialGlobalValue extends Node, TInitialGlobalValue {
665
669
*
666
670
* A node representing an indirection of a parameter.
667
671
*/
668
- class IndirectParameterNode extends Node , IndirectInstruction {
672
+ class IndirectParameterNode extends Node instanceof IndirectInstruction {
669
673
InitializeParameterInstruction init ;
670
674
671
- IndirectParameterNode ( ) { this . getInstruction ( ) = init }
675
+ IndirectParameterNode ( ) { IndirectInstruction . super . hasInstructionAndIndirectionIndex ( init , _ ) }
672
676
673
677
int getArgumentIndex ( ) { init .hasIndex ( result ) }
674
678
@@ -677,7 +681,12 @@ class IndirectParameterNode extends Node, IndirectInstruction {
677
681
678
682
override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
679
683
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
+ }
681
690
682
691
override Location getLocationImpl ( ) { result = this .getParameter ( ) .getLocation ( ) }
683
692
@@ -699,7 +708,8 @@ class IndirectReturnNode extends Node {
699
708
IndirectReturnNode ( ) {
700
709
this instanceof FinalParameterNode
701
710
or
702
- this .( IndirectOperand ) .getOperand ( ) = any ( ReturnValueInstruction ret ) .getReturnAddressOperand ( )
711
+ this .( IndirectOperand )
712
+ .hasOperandAndIndirectionIndex ( any ( ReturnValueInstruction ret ) .getReturnAddressOperand ( ) , _)
703
713
}
704
714
705
715
override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
@@ -722,7 +732,7 @@ class IndirectReturnNode extends Node {
722
732
int getIndirectionIndex ( ) {
723
733
result = this .( FinalParameterNode ) .getIndirectionIndex ( )
724
734
or
725
- result = this .( IndirectOperand ) .getIndirectionIndex ( )
735
+ this .( IndirectOperand ) .hasOperandAndIndirectionIndex ( _ , result )
726
736
}
727
737
}
728
738
@@ -1106,7 +1116,8 @@ predicate exprNodeShouldBeInstruction(Node node, Expr e) {
1106
1116
/** Holds if `node` should be an `IndirectInstruction` that maps `node.asIndirectExpr()` to `e`. */
1107
1117
predicate indirectExprNodeShouldBeIndirectInstruction ( IndirectInstruction node , Expr e ) {
1108
1118
exists ( Instruction instr |
1109
- instr = node .getInstruction ( ) and not indirectExprNodeShouldBeIndirectOperand ( _, e )
1119
+ node .hasInstructionAndIndirectionIndex ( instr , _) and
1120
+ not indirectExprNodeShouldBeIndirectOperand ( _, e )
1110
1121
|
1111
1122
e = instr .( VariableAddressInstruction ) .getAst ( ) .( Expr ) .getFullyConverted ( )
1112
1123
or
@@ -1307,8 +1318,8 @@ pragma[noinline]
1307
1318
private predicate indirectParameterNodeHasArgumentIndexAndIndex (
1308
1319
IndirectParameterNode node , int argumentIndex , int indirectionIndex
1309
1320
) {
1310
- node .getArgumentIndex ( ) = argumentIndex and
1311
- node .getIndirectionIndex ( ) = indirectionIndex
1321
+ node .hasInstructionAndIndirectionIndex ( _ , indirectionIndex ) and
1322
+ node .getArgumentIndex ( ) = argumentIndex
1312
1323
}
1313
1324
1314
1325
/** A synthetic parameter to model the pointed-to object of a pointer parameter. */
@@ -1479,18 +1490,14 @@ VariableNode variableNode(Variable v) {
1479
1490
*/
1480
1491
Node uninitializedNode ( LocalVariable v ) { none ( ) }
1481
1492
1482
- pragma [ noinline]
1483
1493
predicate hasOperandAndIndex ( IndirectOperand indirectOperand , Operand operand , int indirectionIndex ) {
1484
- indirectOperand .getOperand ( ) = operand and
1485
- indirectOperand .getIndirectionIndex ( ) = indirectionIndex
1494
+ indirectOperand .hasOperandAndIndirectionIndex ( operand , indirectionIndex )
1486
1495
}
1487
1496
1488
- pragma [ noinline]
1489
1497
predicate hasInstructionAndIndex (
1490
1498
IndirectInstruction indirectInstr , Instruction instr , int indirectionIndex
1491
1499
) {
1492
- indirectInstr .getInstruction ( ) = instr and
1493
- indirectInstr .getIndirectionIndex ( ) = indirectionIndex
1500
+ indirectInstr .hasInstructionAndIndirectionIndex ( instr , indirectionIndex )
1494
1501
}
1495
1502
1496
1503
cached
@@ -1656,8 +1663,7 @@ module ExprFlowCached {
1656
1663
private predicate isIndirectBaseOfArrayAccess ( IndirectOperand n , Expr e ) {
1657
1664
exists ( LoadInstruction load , PointerArithmeticInstruction pai |
1658
1665
pai = load .getSourceAddress ( ) and
1659
- pai .getLeftOperand ( ) = n .getOperand ( ) and
1660
- n .getIndirectionIndex ( ) = 1 and
1666
+ n .hasOperandAndIndirectionIndex ( pai .getLeftOperand ( ) , 1 ) and
1661
1667
e = load .getConvertedResultExpression ( )
1662
1668
)
1663
1669
}
0 commit comments