Skip to content

Commit f6d0516

Browse files
committed
C#: Adjust the empty location to point to the unique generated empty location.
1 parent 53fb4b0 commit f6d0516

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,27 @@ class Location extends @location {
7474
}
7575

7676
/** An empty location. */
77-
class EmptyLocation extends Location {
78-
EmptyLocation() { this.hasLocationInfo("", 0, 0, 0, 0) }
77+
class EmptyLocation extends Location, @location_default {
78+
EmptyLocation() { locations_default(this, _, -1, -1, -1, -1) }
79+
80+
override predicate hasLocationInfo(
81+
string filepath, int startline, int startcolumn, int endline, int endcolumn
82+
) {
83+
filepath = "" and
84+
startline = 0 and
85+
startcolumn = 0 and
86+
endline = 0 and
87+
endcolumn = 0
88+
}
7989
}
8090

8191
/**
8292
* A location in source code, comprising of a source file and a segment of text
8393
* within the file.
8494
*/
8595
class SourceLocation extends Location, @location_default {
96+
SourceLocation() { not this instanceof EmptyLocation }
97+
8698
/** Gets the location that takes into account `#line` directives, if any. */
8799
SourceLocation getMappedLocation() {
88100
locations_mapped(this, result) and

0 commit comments

Comments
 (0)