From c199d0cbbe70a02311d08758236f2e92958490ba Mon Sep 17 00:00:00 2001 From: Nick Rolfe Date: Fri, 4 Jul 2025 11:43:04 +0100 Subject: [PATCH] Java: use overlayChangedFiles in discard prediactes --- java/ql/lib/semmle/code/Location.qll | 2 +- java/ql/lib/semmle/code/java/Overlay.qll | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/java/ql/lib/semmle/code/Location.qll b/java/ql/lib/semmle/code/Location.qll index 7265164e8e15..fced632a6dd9 100644 --- a/java/ql/lib/semmle/code/Location.qll +++ b/java/ql/lib/semmle/code/Location.qll @@ -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)) } diff --git a/java/ql/lib/semmle/code/java/Overlay.qll b/java/ql/lib/semmle/code/java/Overlay.qll index f1cfc5c434f2..27a2420911e4 100644 --- a/java/ql/lib/semmle/code/java/Overlay.qll +++ b/java/ql/lib/semmle/code/java/Overlay.qll @@ -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. @@ -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()) } /** @@ -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() ) }