Skip to content

Java: use overlayChangedFiles in discard prediactes #20049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java/ql/lib/semmle/code/Location.qll
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,5 @@ private predicate discardableLocation(string file, @location l) {
/** Discard base locations in files fully extracted in the overlay. */
overlay[discard_entity]
private predicate discardLocation(@location l) {
exists(string file | discardableLocation(file, l) and extractedInOverlay(file))
exists(string file | discardableLocation(file, l) and overlayChangedFiles(file))
}
13 changes: 2 additions & 11 deletions java/ql/lib/semmle/code/java/Overlay.qll
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ string getRawFileForLoc(@location l) {
exists(@file f | locations_default(l, f, _, _, _, _) and files(f, result))
}

/** Holds for files fully extracted in the overlay. */
overlay[local]
predicate extractedInOverlay(string file) {
isOverlay() and
// numlines is used to restrict attention to fully extracted files and
// ignore skeleton extracted files in the overlay
exists(@locatable l | numlines(l, _, _, _) and file = getRawFile(l))
}

/**
* A `@locatable` that should be discarded in the base variant if its file is
* extracted in the overlay variant.
Expand All @@ -54,7 +45,7 @@ abstract class DiscardableLocatable extends @locatable {

overlay[discard_entity]
private predicate discardLocatable(@locatable el) {
extractedInOverlay(el.(DiscardableLocatable).getRawFileInBase())
overlayChangedFiles(el.(DiscardableLocatable).getRawFileInBase())
}

/**
Expand All @@ -77,7 +68,7 @@ abstract class DiscardableReferableLocatable extends @locatable {
overlay[discard_entity]
private predicate discardReferableLocatable(@locatable el) {
exists(DiscardableReferableLocatable drl | drl = el |
extractedInOverlay(drl.getRawFileInBase()) and
overlayChangedFiles(drl.getRawFileInBase()) and
not drl.existsInOverlay()
)
}