@@ -81,6 +81,14 @@ class Node0Impl extends TIRDataFlowNode0 {
8181 /** Gets the operands corresponding to this node, if any. */
8282 Operand asOperand ( ) { result = this .( OperandNode0 ) .getOperand ( ) }
8383
84+ /** Gets the location of this node. */
85+ final Location getLocation ( ) { result = this .getLocationImpl ( ) }
86+
87+ /** INTERNAL: Do not use. */
88+ Location getLocationImpl ( ) {
89+ none ( ) // overridden by subclasses
90+ }
91+
8492 /** INTERNAL: Do not use. */
8593 string toStringImpl ( ) {
8694 none ( ) // overridden by subclasses
@@ -131,9 +139,15 @@ abstract class InstructionNode0 extends Node0Impl {
131139 override DataFlowType getType ( ) { result = getInstructionType ( instr , _) }
132140
133141 override string toStringImpl ( ) {
134- // This predicate is overridden in subclasses. This default implementation
135- // does not use `Instruction.toString` because that's expensive to compute.
136- result = instr .getOpcode ( ) .toString ( )
142+ if instr .( InitializeParameterInstruction ) .getIRVariable ( ) instanceof IRThisVariable
143+ then result = "this"
144+ else result = instr .getAst ( ) .toString ( )
145+ }
146+
147+ override Location getLocationImpl ( ) {
148+ if exists ( instr .getAst ( ) .getLocation ( ) )
149+ then result = instr .getAst ( ) .getLocation ( )
150+ else result instanceof UnknownDefaultLocation
137151 }
138152
139153 final override predicate isGLValue ( ) { exists ( getInstructionType ( instr , true ) ) }
@@ -173,7 +187,17 @@ abstract class OperandNode0 extends Node0Impl {
173187
174188 override DataFlowType getType ( ) { result = getOperandType ( op , _) }
175189
176- override string toStringImpl ( ) { result = op .toString ( ) }
190+ override string toStringImpl ( ) {
191+ if op .getDef ( ) .( InitializeParameterInstruction ) .getIRVariable ( ) instanceof IRThisVariable
192+ then result = "this"
193+ else result = op .getDef ( ) .getAst ( ) .toString ( )
194+ }
195+
196+ override Location getLocationImpl ( ) {
197+ if exists ( op .getDef ( ) .getAst ( ) .getLocation ( ) )
198+ then result = op .getDef ( ) .getAst ( ) .getLocation ( )
199+ else result instanceof UnknownDefaultLocation
200+ }
177201
178202 final override predicate isGLValue ( ) { exists ( getOperandType ( op , true ) ) }
179203}
0 commit comments