@@ -143,10 +143,13 @@ class Node extends TIRDataFlowNode {
143
143
/** Gets the function to which this node belongs, if any. */
144
144
Declaration getFunction ( ) { none ( ) } // overridden in subclasses
145
145
146
+ /** Holds if this node represents a glvalue. */
147
+ predicate isGLValue ( ) { none ( ) }
148
+
146
149
/**
147
150
* Gets the type of this node.
148
151
*
149
- * If `asInstruction(). isGLValue()` holds, then the type of this node
152
+ * If `isGLValue()` holds, then the type of this node
150
153
* should be thought of as "pointer to `getType()`".
151
154
*/
152
155
DataFlowType getType ( ) { none ( ) } // overridden in subclasses
@@ -394,6 +397,8 @@ private class Node0 extends Node, TNode0 {
394
397
// does not use `Instruction.toString` because that's expensive to compute.
395
398
result = node .toStringImpl ( )
396
399
}
400
+
401
+ override predicate isGLValue ( ) { node .isGLValue ( ) }
397
402
}
398
403
399
404
/**
@@ -497,7 +502,7 @@ class SsaPhiNode extends Node, TSsaPhiNode {
497
502
498
503
override Declaration getFunction ( ) { result = phi .getBasicBlock ( ) .getEnclosingFunction ( ) }
499
504
500
- override DataFlowType getType ( ) { result = this .getAnInput ( ) .getType ( ) }
505
+ override DataFlowType getType ( ) { result = this .getAnInput ( ) .getType ( ) . getUnspecifiedType ( ) }
501
506
502
507
final override Location getLocationImpl ( ) { result = phi .getBasicBlock ( ) .getLocation ( ) }
503
508
@@ -591,10 +596,14 @@ class InitialGlobalValue extends Node, TInitialGlobalValue {
591
596
592
597
override Declaration getFunction ( ) { result = globalDef .getIRFunction ( ) .getFunction ( ) }
593
598
599
+ final override predicate isGLValue ( ) { globalDef .getIndirectionIndex ( ) = 0 }
600
+
594
601
override DataFlowType getType ( ) {
595
- exists ( int indirectionIndex |
596
- indirectionIndex = globalDef .getIndirectionIndex ( ) and
597
- result = getTypeImpl ( globalDef .getUnspecifiedType ( ) , indirectionIndex )
602
+ exists ( DataFlowType type |
603
+ type = globalDef .getUnspecifiedType ( ) and
604
+ if this .isGLValue ( )
605
+ then result = type
606
+ else result = getTypeImpl ( type , globalDef .getIndirectionIndex ( ) - 1 )
598
607
)
599
608
}
600
609
@@ -843,8 +852,11 @@ class RawIndirectOperand extends Node, TRawIndirectOperand {
843
852
override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
844
853
845
854
override DataFlowType getType ( ) {
846
- exists ( int sub | if operand .isGLValue ( ) then sub = 1 else sub = 0 |
847
- result = getTypeImpl ( operand .getType ( ) .getUnspecifiedType ( ) , indirectionIndex - sub )
855
+ exists ( int sub , DataFlowType type , boolean isGLValue |
856
+ type = getOperandType ( operand , isGLValue ) and
857
+ if isGLValue = true then sub = 1 else sub = 0
858
+ |
859
+ result = getTypeImpl ( type .getUnspecifiedType ( ) , indirectionIndex - sub )
848
860
)
849
861
}
850
862
@@ -938,8 +950,11 @@ class RawIndirectInstruction extends Node, TRawIndirectInstruction {
938
950
override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
939
951
940
952
override DataFlowType getType ( ) {
941
- exists ( int sub | if instr .isGLValue ( ) then sub = 1 else sub = 0 |
942
- result = getTypeImpl ( instr .getResultType ( ) .getUnspecifiedType ( ) , indirectionIndex - sub )
953
+ exists ( int sub , DataFlowType type , boolean isGLValue |
954
+ type = getInstructionType ( instr , isGLValue ) and
955
+ if isGLValue = true then sub = 1 else sub = 0
956
+ |
957
+ result = getTypeImpl ( type .getUnspecifiedType ( ) , indirectionIndex - sub )
943
958
)
944
959
}
945
960
0 commit comments