@@ -143,10 +143,13 @@ class Node extends TIRDataFlowNode {
143143 /** Gets the function to which this node belongs, if any. */
144144 Declaration getFunction ( ) { none ( ) } // overridden in subclasses
145145
146+ /** Holds if this node represents a glvalue. */
147+ predicate isGLValue ( ) { none ( ) }
148+
146149 /**
147150 * Gets the type of this node.
148151 *
149- * If `asInstruction(). isGLValue()` holds, then the type of this node
152+ * If `isGLValue()` holds, then the type of this node
150153 * should be thought of as "pointer to `getType()`".
151154 */
152155 DataFlowType getType ( ) { none ( ) } // overridden in subclasses
@@ -394,6 +397,8 @@ private class Node0 extends Node, TNode0 {
394397 // does not use `Instruction.toString` because that's expensive to compute.
395398 result = node .toStringImpl ( )
396399 }
400+
401+ override predicate isGLValue ( ) { node .isGLValue ( ) }
397402}
398403
399404/**
@@ -497,7 +502,7 @@ class SsaPhiNode extends Node, TSsaPhiNode {
497502
498503 override Declaration getFunction ( ) { result = phi .getBasicBlock ( ) .getEnclosingFunction ( ) }
499504
500- override DataFlowType getType ( ) { result = this .getAnInput ( ) .getType ( ) }
505+ override DataFlowType getType ( ) { result = this .getAnInput ( ) .getType ( ) . getUnspecifiedType ( ) }
501506
502507 final override Location getLocationImpl ( ) { result = phi .getBasicBlock ( ) .getLocation ( ) }
503508
@@ -591,10 +596,14 @@ class InitialGlobalValue extends Node, TInitialGlobalValue {
591596
592597 override Declaration getFunction ( ) { result = globalDef .getIRFunction ( ) .getFunction ( ) }
593598
599+ final override predicate isGLValue ( ) { globalDef .getIndirectionIndex ( ) = 0 }
600+
594601 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 )
598607 )
599608 }
600609
@@ -843,8 +852,11 @@ class RawIndirectOperand extends Node, TRawIndirectOperand {
843852 override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
844853
845854 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 )
848860 )
849861 }
850862
@@ -938,8 +950,11 @@ class RawIndirectInstruction extends Node, TRawIndirectInstruction {
938950 override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
939951
940952 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 )
943958 )
944959 }
945960
0 commit comments