Skip to content

Commit

Permalink
Merge pull request #16172 from owen-mc/go/perf/synth-location
Browse files Browse the repository at this point in the history
Go: Avoid magic in `TSynthLocation` definition
  • Loading branch information
owen-mc authored Apr 10, 2024
2 parents f45305e + a18a4fb commit 0e67aa5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions go/ql/lib/semmle/go/internal/Locations.qll
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ newtype TLocation =
TSynthLocation(string filepath, int startline, int startcolumn, int endline, int endcolumn) {
any(DataFlow::Node n).hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
// avoid overlap with existing DB locations
not exists(File f |
locations_default(_, f, startline, startcolumn, endline, endcolumn) and
f.getAbsolutePath() = filepath
)
not existingDBLocation(filepath, startline, startcolumn, endline, endcolumn)
}

pragma[nomagic]
private predicate existingDBLocation(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
exists(File f |
locations_default(_, f, startline, startcolumn, endline, endcolumn) and
f.getAbsolutePath() = filepath
)
}

/**
* A location as given by a file, a start line, a start column,
* an end line, and an end column.
Expand Down

0 comments on commit 0e67aa5

Please sign in to comment.