Skip to content

Commit 0e67aa5

Browse files
authored
Merge pull request #16172 from owen-mc/go/perf/synth-location
Go: Avoid magic in `TSynthLocation` definition
2 parents f45305e + a18a4fb commit 0e67aa5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

go/ql/lib/semmle/go/internal/Locations.qll

+11-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@ newtype TLocation =
1111
TSynthLocation(string filepath, int startline, int startcolumn, int endline, int endcolumn) {
1212
any(DataFlow::Node n).hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
1313
// avoid overlap with existing DB locations
14-
not exists(File f |
15-
locations_default(_, f, startline, startcolumn, endline, endcolumn) and
16-
f.getAbsolutePath() = filepath
17-
)
14+
not existingDBLocation(filepath, startline, startcolumn, endline, endcolumn)
1815
}
1916

17+
pragma[nomagic]
18+
private predicate existingDBLocation(
19+
string filepath, int startline, int startcolumn, int endline, int endcolumn
20+
) {
21+
exists(File f |
22+
locations_default(_, f, startline, startcolumn, endline, endcolumn) and
23+
f.getAbsolutePath() = filepath
24+
)
25+
}
26+
2027
/**
2128
* A location as given by a file, a start line, a start column,
2229
* an end line, and an end column.

0 commit comments

Comments
 (0)