Conversation
There was a problem hiding this comment.
Pull request overview
Updates the MISRA C++ RULE-7-0-4 CodeQL query to improve evaluation performance by guiding CodeQL’s optimizer for shift-constant range checking.
Changes:
- Added
bindingset[right, leftType]forisValidShiftConstantRange. - Added
pragma[inline_late]to encourage late inlining ofisValidShiftConstantRange.
Show a summary per file
| File | Description |
|---|---|
| cpp/misra/src/rules/RULE-7-0-4/InappropriateBitwiseOrShiftOperands.ql | Adds optimizer hints to the constant-shift-range predicate to improve query performance. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 2
Agent-Logs-Url: https://github.com/github/codeql-coding-standards/sessions/f476011c-d007-4a94-af05-f48e06932289 Co-authored-by: mbaluda <5237080+mbaluda@users.noreply.github.com>
inappropriate-bitwise-or-shift-operandsRULE-6-4-2 RULE-7-0-4
Enhanced performance of the 'isValidShiftConstantRange' predicate by adding annotations for optimization.
There was a problem hiding this comment.
Copilot's findings
Comments suppressed due to low confidence (2)
change_notes/2026-04-25-fix-performance-inappropriate-bitwise-or-shift-operands.md:5
- Change notes typically use past tense for bullet items. Please change "Remove false positives..." to "Removed false positives...".
- Remove false positives related to the `insertion operator`.
cpp/common/src/codingstandards/cpp/rules/hiddeninheritedoverridablememberfunction/HiddenInheritedOverridableMemberFunction.qll:31
- The PR description focuses on the RULE-7-0-4 shift-range predicate, but this PR also changes the shared hidden-inherited-member-function library used by RULE-6-4-2 (and A7-3-1). Please update the PR description to mention this additional functional area so reviewers understand the full scope of the change.
query predicate problems(
OverridingDeclaration overridingDecl, string message, HiddenDeclaration hiddenDecl,
string hiddenDecl_string
) {
- Files reviewed: 3/3 changed files
- Comments generated: 3
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as off-topic.
This comment was marked as off-topic.
|
🏁 Beep Boop! Performance testing complete! See below for performance of the last 3 runs vs your PR. Times are based on predicate performance. You can find full graphs and stats in the PR that was created for this test in the release engineering repo. 🏁 Below are the slowest predicates for the last 2 releases vs this PR. |
RULE-6-4-2 RULE-7-0-4RULE-6-4-2 RULE-7-0-4
| OverridingDeclaration overridingDecl, string message, HiddenDeclaration hiddenDecl, | ||
| string hiddenDecl_string | ||
| ) { |
There was a problem hiding this comment.
problems is a public query predicate, but its parameters are now typed as OverridingDeclaration/HiddenDeclaration, which are declared private in this module. That effectively makes problems hard/impossible to call from other modules (they cannot name these types) and is inconsistent with other shared-query libraries that keep public signatures in terms of public CodeQL types. Consider either making these classes non-private, or keeping the problems signature in terms of FunctionDeclarationEntry and moving the extra constraints into helper predicates/classes used internally.
| OverridingDeclaration overridingDecl, string message, HiddenDeclaration hiddenDecl, | |
| string hiddenDecl_string | |
| ) { | |
| FunctionDeclarationEntry overridingDecl, string message, | |
| FunctionDeclarationEntry hiddenDecl, string hiddenDecl_string | |
| ) { | |
| overridingDecl instanceof OverridingDeclaration and | |
| hiddenDecl instanceof HiddenDeclaration and |
Description
Performance and correctness improvements:
InheritedOverridableMemberFunction.qlandInappropriateBitwiseOrShiftOperands.qlby refactoring query logic and introducing more precise type definitions (OverridingDeclaration,HiddenDeclaration) inHiddenInheritedOverridableMemberFunction.qll. [1] [2] [3] [4]bindingsetandpragmaannotations toisValidShiftConstantRangeinInappropriateBitwiseOrShiftOperands.qlto further improve query performance.Rule naming and documentation updates:
AvoidStandardIntegerTypeNames.qlto clarify that all standard integer types (not just signed/unsigned) should not be used. This change is reflected in the query file, change notes, andBannedAPIs.json. [1] [2] [3]These changes collectively enhance both the efficiency and clarity of the codebase related to C++ coding standard enforcement.
Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.