Skip to content

Commit a405b7b

Browse files
committed
JS: Add discard predicates for locations
1 parent c7341f2 commit a405b7b

File tree

1 file changed

+20
-0
lines changed
  • javascript/ql/lib/semmle/javascript/internal

1 file changed

+20
-0
lines changed

javascript/ql/lib/semmle/javascript/internal/Overlay.qll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,23 @@ overlay[discard_entity]
2828
private predicate discardEntity(@locatable node) {
2929
exists(string file | discardableEntity(file, node) and discardFile(file))
3030
}
31+
32+
overlay[local]
33+
private string getFileFromLocation(@location loc) {
34+
exists(@file file |
35+
locations_default(loc, file, _, _, _, _) and
36+
files(file, result)
37+
)
38+
}
39+
40+
/** Holds if `loc` is in the `file` and is part of the overlay base database. */
41+
overlay[local]
42+
private predicate discardableLocation(string file, @location node) {
43+
not isOverlay() and file = getFileFromLocation(node)
44+
}
45+
46+
/** Holds if `loc` should be discarded, because it is part of the overlay base and is in a file that was also extracted as part of the overlay database. */
47+
overlay[discard_entity]
48+
private predicate discardLocation(@location loc) {
49+
exists(string file | discardableLocation(file, loc) and discardFile(file))
50+
}

0 commit comments

Comments
 (0)