Skip to content

Conversation

@jeongsoolee09
Copy link
Collaborator

@jeongsoolee09 jeongsoolee09 commented Feb 2, 2026

Description

Add Memory2 and Memory3 packages.

Change request type

  • Release or process automation (GitHub workflows, internal scripts)
  • Internal documentation
  • External documentation
  • Query files (.ql, .qll, .qls or unit tests)
  • External scripts (analysis report or other code shipped as part of a release)

Rules with added or modified queries

  • No rules added
  • Queries have been added for the following rules:
    • RULE-8-7-2
    • RULE-8-9-1
  • Queries have been modified for the following rules:
    • rule number here

Release change checklist

A change note (development_handbook.md#change-notes) is required for any pull request which modifies:

  • The structure or layout of the release artifacts.
  • The evaluation performance (memory, execution time) of an existing query.
  • The results of an existing query in any circumstance.

If you are only adding new rule queries, a change note is not required.

Author: Is a change note required?

  • Yes
  • No

🚨🚨🚨
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.

  • Confirmed

Reviewer: Confirm that either a change note is not required or the change note is required and has been added.

  • Confirmed

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

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    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.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

Reviewer

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    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.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

@jeongsoolee09 jeongsoolee09 marked this pull request as ready for review February 2, 2026 23:03
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 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 Memory2 package for RULE-8-7-2 (pointer subtraction validation)
  • Added Memory3 package 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.

Copy link
Collaborator

@MichaelRFairhurst MichaelRFairhurst left a 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

"short_name": "PointerDifferenceTakenBetweenDifferentArrays",
"shared_implementation_short_name": "DoNotSubtractPointersAddressingDifferentArrays",
"tags": [
"scope/system"
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

@MichaelRFairhurst MichaelRFairhurst left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants