Skip to content

Conversation

@jeongsoolee09
Copy link
Collaborator

@jeongsoolee09 jeongsoolee09 commented Feb 6, 2026

Description

Add Memory4 package.

High-level overview

  • M0-2-1 (AUTOSAR C++):
    • DoNotPassAliasedPointerToParam
    • ObjectAssignedToAnOverlappingObject (Factored out)
  • RULE-19-1 (MISRA C):
    • ObjectAssignedToAnOverlappingObject (Factored out)
    • ObjectCopiedToAnOverlappingObject (Factored out)
  • RULE-8-18-1 (MISRA C++):
    • ObjectCopiedToAnOverlappingObject (Imports factored-out shared query)
    • ObjectAssignedToAnOverlappingObject (Imports factored-out shared query)

Step-by-step process overview

  • Edit rule packages for RULE-19-1 and M0-2-1 to add "shared_implementation_short_name"
    • M0-2-1 (existing)
      • Standard: AUTOSAR C++
      • Old "short_name": ObjectAssignedToAnOverlappingObject
      • Package: Representation
      • Edits
        • "shared_implementation_short_name": ObjectAssignedToAnOverlappingObject
        • New "short_name": "ObjectAssignedToAnOverlappingObjectAutosarCpp"
    • RULE-19-1 (existing)
      • Standard: MISRA C
      • Old "short_name" 1: ObjectAssignedToAnOverlappingObject
      • Old "short_name" 2: ObjectCopiedToAnOverlappingObject
      • Package: Contracts7
      • Edits
        • "shared_implementation_short_name" 1: ObjectAssignedToAnOverlappingObject
        • "shared_implementation_short_name" 2: ObjectCopiedToAnOverlappingObject
        • New "short_name" 1: "ObjectAssignedToAnOverlappingObjectMisraC"
        • New "short_name" 2: "ObjectCopiedToAnOverlappingObjectMisraC"
    • RULE-8-18-1 (new)
      • Standard: MISRA C++
      • Package: Memory4
      • Edits
        • "shared_implementation_short_name" 1: ObjectAssignedToAnOverlappingObject
        • "shared_implementation_short_name" 2: ObjectCopiedToAnOverlappingObject
        • New "short_name" 1: "ObjectAssignedToAnOverlappingObjectMisraCpp"
        • New "short_name" 2: "ObjectCopiedToAnOverlappingObjectMisraCpp"
  • (Re-)generate the rule package files
    • # RULE-19-1, MISRA C, Contracts7
      scripts/.venv/bin/python3.14 scripts/generate_rules/generate_package_files.py c Contracts7
      
      # M0-2-1, AUTOSAR C++, Representation
      scripts/.venv/bin/python3.14 scripts/generate_rules/generate_package_files.py cpp Representation
      
      # RULE-8-18-1, MISRA C++, Memory4
      scripts/.venv/bin/python3.14 scripts/generate_rules/generate_package_files.py cpp Memory4
  • Confirm that the rule package files are created, and if so delete the existing query + md
    • RULE-19-1 (Contracts7)
    • M0-2-1 (Representation)
  • Copy-paste the shared query
    • cpp/common/src/codingstandards/cpp/rules/objectassignedtoanoverlappingobject/ObjectAssignedToAnOverlappingObject.qll
    • cpp/common/src/codingstandards/cpp/rules/objectcopiedtoanoverlappingobject/ObjectCopiedToAnOverlappingObject.qll
  • Turn the from-where-select into a query predicate problem in the file right above (step 4)
    • cpp/common/src/codingstandards/cpp/rules/objectassignedtoanoverlappingobject/ObjectAssignedToAnOverlappingObject.qll
    • cpp/common/src/codingstandards/cpp/rules/objectcopiedtoanoverlappingobject/ObjectCopiedToAnOverlappingObject.qll
  • Remove the testref files are created, and if so delete the existing qlref + expected + test.c
    • RULE-19-1 (Contracts7)
    • M0-2-1 (Representation)
  • Copy-paste the test code
    • cpp/common/test/rules/objectassignedtoanoverlappingobject/test.cpp
    • cpp/common/test/rules/objectcopiedtoanoverlappingobject/test.cpp

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-18-1
  • Queries have been modified for the following rules:
    • M0-2-1
    • RULE-19-1

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!)

Copilot AI review requested due to automatic review settings February 6, 2026 00:07
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 the Memory4 package for MISRA C++ and refactors shared query implementations for detecting overlapping object operations across multiple coding standards (MISRA C, MISRA C++, and AUTOSAR C++).

Changes:

  • Adds new Memory4 package for MISRA C++ RULE-8-18-1
  • Refactors ObjectAssignedToAnOverlappingObject and ObjectCopiedToAnOverlappingObject queries into shared implementations
  • Updates existing queries in Representation (AUTOSAR C++) and Contracts7 (MISRA C) packages to use the new shared implementations

Reviewed changes

Copilot reviewed 37 out of 40 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
rules.csv Updates RULE-8-18-1 package assignment
rule_packages/cpp/Memory4.json New package definition for MISRA C++ Memory4 queries
rule_packages/cpp/Representation.json Updates query naming to include suffix and shared implementation reference
rule_packages/c/Contracts7.json Updates query naming to include suffix and shared implementation reference
cpp/common/src/codingstandards/cpp/rules/objectassignedtoanoverlappingobject/ObjectAssignedToAnOverlappingObject.qll New shared implementation for overlapping assignment detection
cpp/common/src/codingstandards/cpp/rules/objectcopiedtoanoverlappingobject/ObjectCopiedToAnOverlappingObject.qll Refactored shared implementation for overlapping copy detection
cpp/common/src/codingstandards/cpp/exclusions/cpp/Memory4.qll New exclusion metadata for Memory4 package
cpp/common/src/codingstandards/cpp/exclusions/cpp/Representation.qll Updated query references for renamed queries
cpp/common/src/codingstandards/cpp/exclusions/c/Contracts7.qll Updated query references for renamed queries
cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll Added Memory4 package integration
cpp/misra/src/rules/RULE-8-18-1/* New MISRA C++ query implementations
cpp/autosar/src/rules/M0-2-1/* Refactored AUTOSAR C++ query to use shared implementation
c/misra/src/rules/RULE-19-1/* Refactored MISRA C query to use shared implementation
/test/ Updated test infrastructure for all affected queries

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The module `codingstandards.cpp.SimpleRangeAnalysisCustomizations` is
included in `codingstandards.c.misra` which this query doesn't import
anymore from being shared. Therefore, manually include it in the import
list.
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.

1 participant