Skip to content
Open
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
18 changes: 14 additions & 4 deletions cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,27 @@ private string getMultiLocationFilePath(@element e) {
overlay[local]
private predicate isBase() { not isOverlay() }

/**
* Holds if `path` was extracted in the overlay database.
*/
overlay[local]
private predicate overlayHasFile(string path) {
isOverlay() and
files(_, path) and
path != ""
}

/**
* Discards an element from the base variant if:
* - It has a single location in a changed file, or
* - All of its locations are in changed files.
* - It has a single location in a file extracted in the overlay, or
* - All of its locations are in files extracted in the overlay.
*/
overlay[discard_entity]
private predicate discardElement(@element e) {
isBase() and
(
overlayChangedFiles(getSingleLocationFilePath(e))
overlayHasFile(getSingleLocationFilePath(e))
or
forex(string path | path = getMultiLocationFilePath(e) | overlayChangedFiles(path))
forex(string path | path = getMultiLocationFilePath(e) | overlayHasFile(path))
)
}
Loading