Skip to content

Conversation

@kaspersv
Copy link
Contributor

@kaspersv kaspersv commented May 27, 2025

This PR adds a QL-for-QL query to warn about possible non-inlining across the overlay frontier for possibly local non-private inline predicates. It will be used in tandem with a script to automatically add overlay annotations to files without existing overlay annotations. Once locality annotations have been added to a file, this query takes over responsibility for warning about possible non-inlining.

Due to a limitation of the tree-sitter-ql grammar with respect to annotations on file-level module declarations (i.e., module;), the heuristic for determining whether an inline predicate might be local is very crude: if the file contains any overlay[local] or overlay[local?] annotations.

For https://github.com/github/codeql-core/issues/4951.

@kaspersv kaspersv force-pushed the kaspersv/overlay-inline-warning branch from a67d865 to ac94145 Compare May 28, 2025 12:17
@kaspersv kaspersv force-pushed the kaspersv/overlay-inline-warning branch from ac94145 to b291b06 Compare May 28, 2025 12:41
@kaspersv kaspersv marked this pull request as ready for review May 30, 2025 11:25
Copilot AI review requested due to automatic review settings May 30, 2025 11:25
@kaspersv kaspersv requested a review from a team as a code owner May 30, 2025 11:25
Copy link
Contributor

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

Adds a CodeQL query to warn when local inline predicates lack an overlay[caller] annotation and the supporting AST classes to recognize new overlay annotations.

  • Introduces InlineOverlayCaller.ql to flag non-private inline predicates in files with overlay[local]/overlay[local?] annotations.
  • Extends the AST model in Ast.qll with new AnnotationArg and Annotation subclasses for overlay[caller], overlay[local], and overlay[local?].

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
ql/ql/src/queries/overlay/InlineOverlayCaller.ql New query to detect and warn about inline predicates crossing an overlay frontier.
ql/ql/src/codeql_ql/ast/Ast.qll Added CallerArg, LocalArg, LocalQArg and corresponding OverlayCaller, OverlayLocal, OverlayLocalQ classes.
Comments suppressed due to low confidence (1)

ql/ql/src/codeql_ql/ast/Ast.qll:2541

  • [nitpick] The class name CallerArg is generic. Consider renaming it to OverlayCallerArg (and similarly LocalArg to OverlayLocalArg, LocalQArg to OverlayLocalQArg) for clarity and consistency.
private class CallerArg extends AnnotationArg {

@ginsbach ginsbach self-requested a review June 10, 2025 12:21
@kaspersv kaspersv requested review from aschackmull and asgerf June 11, 2025 12:25
@kaspersv kaspersv changed the title Add QL for QL query to warn about possible non-inlining across overlay frontier Overlay: Add QL for QL query to warn about possible non-inlining across overlay frontier Jun 17, 2025
@kaspersv kaspersv merged commit 7f38a7f into github:main Jun 17, 2025
12 checks passed
Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

Would have been nice with a few tests as well.

@kaspersv kaspersv deleted the kaspersv/overlay-inline-warning branch July 1, 2025 07:24
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