@@ -45,8 +45,10 @@ class Operand extends TStageOperand {
4545
4646 /**
4747 * Gets the location of the source code for this operand.
48+ * By default this is where the operand is used, but some subclasses may override this
49+ * using getAnyDef() if it makes more sense.
4850 */
49- final Language:: Location getLocation ( ) { result = this .getAnyDef ( ) .getLocation ( ) }
51+ Language:: Location getLocation ( ) { result = this .getUse ( ) .getLocation ( ) }
5052
5153 /**
5254 * Gets the function that contains this operand.
@@ -269,6 +271,10 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
269271
270272 final override string toString ( ) { result = tag .toString ( ) }
271273
274+ // most RegisterOperands have a more meaningful location at the definition
275+ // the only exception is ThisArgumentOperand
276+ override Language:: Location getLocation ( ) { result = this .getAnyDef ( ) .getLocation ( ) }
277+
272278 final override Instruction getAnyDef ( ) { result = defInstr }
273279
274280 final override Overlap getDefinitionOverlap ( ) {
@@ -406,6 +412,11 @@ class ArgumentOperand extends RegisterOperand {
406412 */
407413class ThisArgumentOperand extends ArgumentOperand {
408414 override ThisArgumentOperandTag tag ;
415+
416+ // in some cases the def location seems to make more sense, but most of the
417+ // time it does not really make a difference, and on some occations the def
418+ // has no location at all, so that in general it is better use the use location
419+ override Language:: Location getLocation ( ) { result = this .getUse ( ) .getLocation ( ) }
409420}
410421
411422/**
0 commit comments