Skip to content

QL4QL: Discard predicates are always alive #20013

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

Conversation

kaspersv
Copy link
Contributor

@kaspersv kaspersv commented Jul 10, 2025

Private discard entity predicates are currently marked as dead code by the QL4QL dead code query. This PR updates the query such that discard predicates are always considered alive.

@kaspersv kaspersv force-pushed the kaspersv/ql4ql-discard-entity-preds-alive branch from 8533643 to 1723c6e Compare July 10, 2025 09:09
@kaspersv kaspersv requested a review from nickrolfe July 10, 2025 09:55
@kaspersv kaspersv marked this pull request as ready for review July 10, 2025 09:55
@Copilot Copilot AI review requested due to automatic review settings July 10, 2025 09:55
@kaspersv kaspersv requested a review from a team as a code owner July 10, 2025 09:55
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements support for discard predicates in the dead code analysis for QL4QL. Discard predicates, annotated with overlay[discard_entity], are now recognized as always alive and excluded from dead code detection.

  • Adds AST support for recognizing overlay[discard_entity] annotations
  • Updates the dead code analysis to treat discard predicates as alive
  • Includes test coverage for the new functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
ql/ql/src/codeql_ql/ast/Ast.qll Adds AST support for parsing overlay[discard_entity] annotations
ql/ql/src/codeql_ql/style/DeadCodeQuery.qll Updates dead code analysis to treat discard predicates as alive
ql/ql/test/queries/style/DeadCode/Foo.qll Adds test case for discard predicate functionality

hvitved
hvitved previously approved these changes Jul 10, 2025
Copy link
Contributor

@nickrolfe nickrolfe left a comment

Choose a reason for hiding this comment

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

Looks sensible.

@kaspersv kaspersv merged commit 767d55b into github:main Jul 10, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy