Skip to content

C++ overlay: Discarding elements#21281

Open
igfoo wants to merge 3 commits intogithub:mainfrom
igfoo:igfoo/discarding
Open

C++ overlay: Discarding elements#21281
igfoo wants to merge 3 commits intogithub:mainfrom
igfoo:igfoo/discarding

Conversation

@igfoo
Copy link
Member

@igfoo igfoo commented Feb 5, 2026

This adds trap_filename, source_file_uses_trap and in_trap for C++ overlay support.

@github-actions github-actions bot added the C++ label Feb 5, 2026
@igfoo igfoo changed the title XXX C++ overlay: Discarding elements Feb 6, 2026
@igfoo igfoo marked this pull request as ready for review February 6, 2026 17:30
@igfoo igfoo requested a review from a team as a code owner February 6, 2026 17:30
Copilot AI review requested due to automatic review settings February 6, 2026 17:30
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

This pull request adds support for C++ overlay functionality by introducing three new database relations: trap_filename, source_file_uses_trap, and in_trap. These relations enable tracking of TRAP file associations with source files and elements, which is essential for overlay mode operations where the system needs to identify which definitions come from which TRAP files.

Changes:

  • Added three new database schema relations for tracking TRAP file relationships
  • Created upgrade scripts to add the new relations to existing databases
  • Created downgrade scripts to remove the relations when reverting the schema

Reviewed changes

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

Show a summary per file
File Description
cpp/ql/lib/semmlecode.cpp.dbscheme Adds three new relations (trap_filename, source_file_uses_trap, in_trap) to the main C++ database schema
cpp/ql/lib/upgrades/9439176c1d1312787926458dd54d65a849069118/upgrade.properties Defines the upgrade metadata with description and compatibility level
cpp/ql/lib/upgrades/9439176c1d1312787926458dd54d65a849069118/old.dbscheme Contains the baseline schema before the changes (without the new relations)
cpp/downgrades/7e7c2f55670f8123d514cf542ccb1938118ac561/upgrade.properties Defines the downgrade metadata and specifies deletion of the three new relations
cpp/downgrades/7e7c2f55670f8123d514cf542ccb1938118ac561/semmlecode.dbscheme Contains the target schema after downgrade (without the new relations)
cpp/downgrades/7e7c2f55670f8123d514cf542ccb1938118ac561/old.dbscheme Contains the baseline schema before downgrade (with the new relations)
Comments suppressed due to low confidence (2)

cpp/ql/lib/semmlecode.cpp.dbscheme:257

  • The source_file_uses_trap relation lacks a keyset declaration. Consider adding #keyset[source_file, trap_file] to specify the primary key for this relation. This would clarify whether a source file can use multiple trap files or if the combination should be unique.
source_file_uses_trap(
    string source_file: string ref,
    int trap_file: @trap ref
);

cpp/ql/lib/semmlecode.cpp.dbscheme:265

  • The in_trap relation lacks a keyset declaration. Consider adding #keyset[element, trap_file] to specify the primary key for this relation. This would clarify the uniqueness constraints and whether an element can be defined in multiple trap files.
in_trap(
    int element: @element ref,
    int trap_file: @trap ref
);

Comment on lines +243 to +246
trap_filename(
int trap: @trap,
string filename: string ref
);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The type @trap is used in the new relations but is never defined in the schema. Database schema types must be defined before they can be referenced. You should add a definition for @trap, similar to how @pch, @compilation, and other types are defined. This could be either a primitive type definition or a union type definition depending on what @trap represents.

Copilot uses AI. Check for mistakes.
Comment on lines +243 to +246
trap_filename(
int trap: @trap,
string filename: string ref
);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The trap_filename relation lacks a keyset declaration. Consider adding #keyset[trap] or unique int trap: @trap constraint to clarify the primary key and ensure data integrity. Looking at similar relations in the schema (e.g., pch_uses at line 267), relations typically have explicit key constraints defined.

This issue also appears in the following locations of the same file:

  • line 254
  • line 262

Copilot uses AI. Check for mistakes.
Comment on lines +243 to +246
trap_filename(
int trap: @trap,
string filename: string ref
);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The same undefined type @trap issue exists in the downgrade old.dbscheme file. This file should match the main schema after the upgrade, so it must also define the @trap type.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant