@@ -45,8 +45,10 @@ class Operand extends TStageOperand {
45
45
46
46
/**
47
47
* 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.
48
50
*/
49
- final Language:: Location getLocation ( ) { result = this .getAnyDef ( ) .getLocation ( ) }
51
+ Language:: Location getLocation ( ) { result = this .getUse ( ) .getLocation ( ) }
50
52
51
53
/**
52
54
* Gets the function that contains this operand.
@@ -269,6 +271,10 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
269
271
270
272
final override string toString ( ) { result = tag .toString ( ) }
271
273
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
+
272
278
final override Instruction getAnyDef ( ) { result = defInstr }
273
279
274
280
final override Overlap getDefinitionOverlap ( ) {
@@ -406,6 +412,11 @@ class ArgumentOperand extends RegisterOperand {
406
412
*/
407
413
class ThisArgumentOperand extends ArgumentOperand {
408
414
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 ( ) }
409
420
}
410
421
411
422
/**
0 commit comments