-
Notifications
You must be signed in to change notification settings - Fork 74
Add Memory2 and Memory3 package
#1023
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 adds two new rule packages (Memory2 and Memory3) to implement MISRA C++ 2023 pointer safety rules RULE-8-7-2 and RULE-8-9-1, which enforce that pointer arithmetic operations (subtraction and relational comparisons) should only be performed on pointers addressing elements of the same array.
Changes:
- Added
Memory2package for RULE-8-7-2 (pointer subtraction validation) - Added
Memory3package for RULE-8-9-1 (pointer relational comparison validation) - Updated rules.csv to assign these new packages to existing rule entries
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| rules.csv | Updated package assignments for RULE-8-7-1, RULE-8-7-2, and RULE-8-9-1 from Memory/uncommitted to Memory1/Memory2/Memory3 |
| rule_packages/cpp/Memory2.json | Added package metadata for RULE-8-7-2 pointer subtraction validation query |
| rule_packages/cpp/Memory3.json | Added package metadata for RULE-8-9-1 pointer comparison validation query |
| cpp/misra/src/rules/RULE-8-7-2/PointerDifferenceTakenBetweenDifferentArrays.ql | Implemented query for detecting pointer subtraction between different arrays |
| cpp/misra/src/rules/RULE-8-9-1/PointerComparedBetweenDifferentArrays.ql | Implemented query for detecting pointer comparisons between different arrays |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Memory2.qll | Generated metadata for Memory2 package query registration |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Memory3.qll | Generated metadata for Memory3 package query registration |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll | Added imports and registrations for Memory2 and Memory3 packages |
| cpp/misra/test/rules/RULE-8-7-2/* | Added test infrastructure files for RULE-8-7-2 |
| cpp/misra/test/rules/RULE-8-9-1/* | Added test infrastructure files for RULE-8-9-1 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cpp/misra/test/rules/RULE-8-9-1/PointerComparedBetweenDifferentArrays.testref
Outdated
Show resolved
Hide resolved
MichaelRFairhurst
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Just one metadata comment only
rule_packages/cpp/Memory2.json
Outdated
| "short_name": "PointerDifferenceTakenBetweenDifferentArrays", | ||
| "shared_implementation_short_name": "DoNotSubtractPointersAddressingDifferentArrays", | ||
| "tags": [ | ||
| "scope/system" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the "correctness" tag to these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! I've also added it to Memory3, in 017f019.
Description
Add
Memory2andMemory3packages.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.