Skip to content

Commit 16e9e8e

Browse files
authored
Merge pull request #20049 from github/nickrolfe/java-deleted-files
Java: use `overlayChangedFiles` in discard prediactes
2 parents 2ed54d5 + c199d0c commit 16e9e8e

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,5 @@ private predicate discardableLocation(string file, @location l) {
233233
/** Discard base locations in files fully extracted in the overlay. */
234234
overlay[discard_entity]
235235
private predicate discardLocation(@location l) {
236-
exists(string file | discardableLocation(file, l) and extractedInOverlay(file))
236+
exists(string file | discardableLocation(file, l) and overlayChangedFiles(file))
237237
}

java/ql/lib/semmle/code/java/Overlay.qll

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ string getRawFileForLoc(@location l) {
3030
exists(@file f | locations_default(l, f, _, _, _, _) and files(f, result))
3131
}
3232

33-
/** Holds for files fully extracted in the overlay. */
34-
overlay[local]
35-
predicate extractedInOverlay(string file) {
36-
isOverlay() and
37-
// numlines is used to restrict attention to fully extracted files and
38-
// ignore skeleton extracted files in the overlay
39-
exists(@locatable l | numlines(l, _, _, _) and file = getRawFile(l))
40-
}
41-
4233
/**
4334
* A `@locatable` that should be discarded in the base variant if its file is
4435
* extracted in the overlay variant.
@@ -54,7 +45,7 @@ abstract class DiscardableLocatable extends @locatable {
5445

5546
overlay[discard_entity]
5647
private predicate discardLocatable(@locatable el) {
57-
extractedInOverlay(el.(DiscardableLocatable).getRawFileInBase())
48+
overlayChangedFiles(el.(DiscardableLocatable).getRawFileInBase())
5849
}
5950

6051
/**
@@ -77,7 +68,7 @@ abstract class DiscardableReferableLocatable extends @locatable {
7768
overlay[discard_entity]
7869
private predicate discardReferableLocatable(@locatable el) {
7970
exists(DiscardableReferableLocatable drl | drl = el |
80-
extractedInOverlay(drl.getRawFileInBase()) and
71+
overlayChangedFiles(drl.getRawFileInBase()) and
8172
not drl.existsInOverlay()
8273
)
8374
}

0 commit comments

Comments
 (0)