Skip to content

Commit 457e9b3

Browse files
committed
C#: Use the location of the unbound declaration.
1 parent df369fd commit 457e9b3

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

csharp/ql/lib/semmle/code/csharp/Callable.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,7 @@ class Method extends Callable, Virtualizable, Attributable, @method {
265265
result = Virtualizable.super.getAnUltimateImplementor()
266266
}
267267

268-
override Location getALocation() {
269-
exists(Method m | m = this.getUnboundDeclaration() | method_location(m, result))
270-
}
268+
override Location getALocation() { method_location(this.getUnboundDeclaration(), result) }
271269

272270
/** Holds if this method is an extension method. */
273271
predicate isExtensionMethod() { this.getParameter(0).hasExtensionMethodModifier() }

csharp/ql/lib/semmle/code/csharp/Event.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class Event extends DeclarationWithAccessors, @event {
6868
result = DeclarationWithAccessors.super.getAnUltimateImplementor()
6969
}
7070

71-
override Location getALocation() { event_location(this, result) }
71+
override Location getALocation() { event_location(this.getUnboundDeclaration(), result) }
7272

7373
override string getAPrimaryQlClass() { result = "Event" }
7474
}
@@ -99,7 +99,7 @@ class EventAccessor extends Accessor, @event_accessor {
9999

100100
override Event getDeclaration() { event_accessors(this, _, _, result, _) }
101101

102-
override Location getALocation() { event_accessor_location(this, result) }
102+
override Location getALocation() { event_accessor_location(this.getUnboundDeclaration(), result) }
103103
}
104104

105105
/**

csharp/ql/lib/semmle/code/csharp/Property.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class Property extends DeclarationWithGetSetAccessors, @property {
196196

197197
override PropertyAccess getAnAccess() { result.getTarget() = this }
198198

199-
override Location getALocation() { property_location(this, result) }
199+
override Location getALocation() { property_location(this.getUnboundDeclaration(), result) }
200200

201201
override Expr getAnAssignedValue() {
202202
result = DeclarationWithGetSetAccessors.super.getAnAssignedValue()
@@ -328,7 +328,7 @@ class Indexer extends DeclarationWithGetSetAccessors, Parameterizable, @indexer
328328
result = DeclarationWithGetSetAccessors.super.getAnUltimateImplementor()
329329
}
330330

331-
override Location getALocation() { indexer_location(this, result) }
331+
override Location getALocation() { indexer_location(this.getUnboundDeclaration(), result) }
332332

333333
override string toStringWithTypes() {
334334
result = this.getName() + "[" + this.parameterTypesToString() + "]"
@@ -408,7 +408,7 @@ class Accessor extends Callable, Modifiable, Attributable, Overridable, @callabl
408408

409409
override Accessor getUnboundDeclaration() { accessors(this, _, _, _, result) }
410410

411-
override Location getALocation() { accessor_location(this, result) }
411+
override Location getALocation() { accessor_location(this.getUnboundDeclaration(), result) }
412412

413413
override string toString() { result = this.getName() }
414414
}

0 commit comments

Comments
 (0)