Skip to content

Overlay: Add manual Java overlay annotations & discard predicates #19813

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kaspersv
Copy link
Contributor

@kaspersv kaspersv commented Jun 18, 2025

This PR builds on top of #19779, adding a few additional manual overlay annotations and defining entity discard predicates for Java.

The overlay[local?] annotations in the experimental queries are needed to ensure that virtual dispatch (which depends indirectly on ActiveExperimentalModels) becomes local. In addition to the manual overlay[local?] annotations, the PR adds an overlay[global] annotation in DataFlowImplCommon.qll to ensure lambda flow is global.

The entity discard predicates defined in this PR are not exhaustive and additional discarding may be needed. The PR adds entity discard predicates to discard the following:

  • base locations, expressions, javadocs, statements and local scoped variables in files fully extracted in the overlay
  • base methods on anonymous classes in files fully extracted in the overlay
  • base methods in files fully extracted in the overlay that are not used in the overlay

@kaspersv kaspersv force-pushed the kaspersv/overlay-java-discarding branch from 6f5bc41 to 8672313 Compare June 19, 2025 06:34
@kaspersv kaspersv force-pushed the kaspersv/overlay-java-discarding branch from 8672313 to db52a3c Compare June 19, 2025 07:13
@kaspersv kaspersv force-pushed the kaspersv/overlay-java-discarding branch from db52a3c to 26896ea Compare June 20, 2025 11:39
@kaspersv kaspersv force-pushed the kaspersv/overlay-java-discarding branch from bdf1bdd to 3c2c871 Compare June 23, 2025 13:00
@kaspersv kaspersv changed the title Java: Add manual overlay annotations & discard predicates Overlay: Add manual Java overlay annotations & discard predicates Jun 24, 2025
@kaspersv kaspersv force-pushed the kaspersv/overlay-java-annotations branch from 052023e to 81b677a Compare June 24, 2025 08:26
@kaspersv kaspersv force-pushed the kaspersv/overlay-java-discarding branch from 3c2c871 to 0ee6a78 Compare June 24, 2025 08:38
@kaspersv kaspersv marked this pull request as ready for review June 25, 2025 06:03
@kaspersv kaspersv requested a review from a team as a code owner June 25, 2025 06:03
@kaspersv kaspersv requested a review from aschackmull June 25, 2025 06:03
@kaspersv kaspersv added the no-change-note-required This PR does not need a change note label Jun 25, 2025
@kaspersv
Copy link
Contributor Author

The Compile all queries CI check should succeed once the next CLI is released.

jbj
jbj previously approved these changes Jun 25, 2025
Copy link
Contributor

@jbj jbj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this if @aschackmull is happy

Copy link
Contributor

@aschackmull aschackmull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can simplify the boilerplate somewhat.

@kaspersv kaspersv requested a review from aschackmull June 25, 2025 14:59
@kaspersv kaspersv force-pushed the kaspersv/overlay-java-discarding branch from 54589c8 to bcadf31 Compare June 25, 2025 15:08
@kaspersv kaspersv force-pushed the kaspersv/overlay-java-discarding branch from bcadf31 to a9f1540 Compare June 26, 2025 09:18
@kaspersv kaspersv force-pushed the kaspersv/overlay-java-discarding branch from a9f1540 to 64f27e2 Compare June 26, 2025 09:36
@kaspersv kaspersv requested a review from aschackmull June 26, 2025 09:46
aschackmull
aschackmull previously approved these changes Jun 26, 2025
Copy link
Contributor

@aschackmull aschackmull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from kaspersv/overlay-java-annotations to main June 27, 2025 06:26
@kaspersv kaspersv dismissed stale reviews from aschackmull and jbj June 27, 2025 06:26

The base branch was changed.

@@ -221,3 +222,16 @@
not hasSourceLocation(l, _, _) and
locations_default(loc, f, _, _, _, _)
}

overlay[local]
private predicate discardableLocation(string file, @location l) {

Check warning

Code scanning / CodeQL

Dead code Warning

This code is never used, and it's not publicly exported.

/** Discard base locations in files fully extracted in the overlay. */
overlay[discard_entity]
private predicate discardLocation(@location l) {

Check warning

Code scanning / CodeQL

Dead code Warning

This code is never used, and it's not publicly exported.
Comment on lines +6 to +10
/**
* A local predicate that always holds for the overlay variant and
* never holds for the base variant. This is used to define local
* predicates that behave differently for the base and overlay variant.
*/

Check warning

Code scanning / CodeQL

Predicate QLDoc style. Warning

The QLDoc for a predicate without a result should start with 'Holds'.
}

overlay[discard_entity]
private predicate discardLocatable(@locatable el) {

Check warning

Code scanning / CodeQL

Dead code Warning

This code is never used, and it's not publicly exported.
}

overlay[discard_entity]
private predicate discardReferableLocatable(@locatable el) {

Check warning

Code scanning / CodeQL

Dead code Warning

This code is never used, and it's not publicly exported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DataFlow Library Java no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants