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
| value = right.getValue().toInt() and | ||
| value >= 0 and | ||
| value < leftType.getSize() * 8 | ||
| value < leftType.getBuiltInSize() * 8 |
There was a problem hiding this comment.
Can we add tests for this?
Is this error related to references?
Description
This pull request focuses on improving the performance and accuracy of two C++ static analysis rules, particularly related to inherited overridable member functions and inappropriate bitwise or shift operands. The changes include performance optimizations, reduction of false positives, and refactoring for better type safety and maintainability.
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.