Skip to content

Add Banned7 package#1105

Open
jeongsoolee09 wants to merge 6 commits intomainfrom
jeongsoolee09/MISRA-C++-2023-Banned7
Open

Add Banned7 package#1105
jeongsoolee09 wants to merge 6 commits intomainfrom
jeongsoolee09/MISRA-C++-2023-Banned7

Conversation

@jeongsoolee09
Copy link
Copy Markdown
Collaborator

@jeongsoolee09 jeongsoolee09 commented Apr 7, 2026

Description

Add rule package Banned7 that contains Rule 21.6.1.

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

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 April 9, 2026 02:37
Copilot AI review requested due to automatic review settings April 9, 2026 02:37
Copy link
Copy Markdown
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

Adds a new MISRA C++:2023 rule package (Banned7) and implements RULE-21-6-1 (“Dynamic memory should not be used”) as a new CodeQL query, with accompanying tests and supporting library/stub updates.

Changes:

  • Introduces Banned7 rule package metadata and wires RULE-21-6-1 to it in rules.csv.
  • Adds the new RULE-21-6-1 query and a comprehensive unit test (+ .expected/.qlref).
  • Factors shared dynamic-memory modeling helpers into codingstandards.cpp.DynamicMemory and updates RULE-21-6-2 to use it; expands C++ standard-library stubs to support the new test.
Show a summary per file
File Description
rules.csv Re-points RULE-21-6-1 to the new Banned7 package.
rule_packages/cpp/Banned7.json Adds package metadata for RULE-21-6-1.
cpp/misra/src/rules/RULE-21-6-1/DynamicMemoryShouldNotBeUsed.ql Implements the new RULE-21-6-1 query and alert messaging.
cpp/misra/src/rules/RULE-21-6-2/DynamicMemoryManagedManually.ql Refactors to reuse shared dynamic-memory modeling from a common library.
cpp/common/src/codingstandards/cpp/DynamicMemory.qll Introduces shared modeling for placement-new operators and std allocator allocate/deallocate members.
cpp/common/src/codingstandards/cpp/exclusions/cpp/Banned7.qll Adds the autogenerated exclusions/metadata wrapper for the new package query.
cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll Registers Banned7 so exclusions/metadata plumbing recognizes it.
cpp/misra/test/rules/RULE-21-6-1/test.cpp Adds unit tests covering many direct/indirect allocation/deallocation scenarios.
cpp/misra/test/rules/RULE-21-6-1/DynamicMemoryShouldNotBeUsed.qlref Links the test to the production RULE-21-6-1 query.
cpp/misra/test/rules/RULE-21-6-1/DynamicMemoryShouldNotBeUsed.expected Adds expected results for RULE-21-6-1 test cases.
cpp/common/test/includes/standard-library/any.h Adds stub declarations for std::any used by tests.
cpp/common/test/includes/standard-library/any Adds wrapper include for <any>.
cpp/common/test/includes/standard-library/bitset.h Adds stub declarations for std::bitset used by tests.
cpp/common/test/includes/standard-library/bitset Adds wrapper include for <bitset>.
cpp/common/test/includes/standard-library/deque.h Adjusts std::deque stub constructors/includes used by tests.
cpp/common/test/includes/standard-library/filesystem.h Adds stub declarations for std::filesystem::path used by tests.
cpp/common/test/includes/standard-library/filesystem Adds wrapper include for <filesystem>.
cpp/common/test/includes/standard-library/forward_list.h Adds stub declarations for std::forward_list used by tests.
cpp/common/test/includes/standard-library/forward_list Adds wrapper include for <forward_list>.
cpp/common/test/includes/standard-library/fstream.h Expands stream stubs/aliases used by tests.
cpp/common/test/includes/standard-library/fstream Adds wrapper include for <fstream>.
cpp/common/test/includes/standard-library/functional.h Extends reference_wrapper stub to support test usage.
cpp/common/test/includes/standard-library/future.h Adds stubs for std::future/promise/async used by tests.
cpp/common/test/includes/standard-library/future Adds wrapper include for <future>.
cpp/common/test/includes/standard-library/istream.h Minor include-guard formatting change.
cpp/common/test/includes/standard-library/list.h Adds stub declarations for std::list used by tests.
cpp/common/test/includes/standard-library/list Adds wrapper include for <list>.
cpp/common/test/includes/standard-library/map Adds constructors/initializer_list support to map/multimap stubs for tests.
cpp/common/test/includes/standard-library/memory.h Adjusts smart pointer/allocator-related stubs used by tests.
cpp/common/test/includes/standard-library/optional Minor include-guard formatting change.
cpp/common/test/includes/standard-library/queue.h Adds stub declarations for std::queue/priority_queue used by tests.
cpp/common/test/includes/standard-library/queue Adds wrapper include for <queue>.
cpp/common/test/includes/standard-library/regex.h Adds stub declarations for std::regex used by tests.
cpp/common/test/includes/standard-library/regex Adds wrapper include for <regex>.
cpp/common/test/includes/standard-library/set Adds constructors/initializer_list support to set/multiset stubs for tests.
cpp/common/test/includes/standard-library/sstream.h Expands stringstream/istringstream/ostringstream stubs and aliases for tests.
cpp/common/test/includes/standard-library/stack.h Adds stub declarations for std::stack used by tests.
cpp/common/test/includes/standard-library/stack Adds wrapper include for <stack>.
cpp/common/test/includes/standard-library/string Adds wstring/u16string/u32string aliases for tests.
cpp/common/test/includes/standard-library/tuple.h Expands tuple stub constructors/templates used by tests.
cpp/common/test/includes/standard-library/unordered_map.h Adds unordered_(multi)map stubs used by tests.
cpp/common/test/includes/standard-library/unordered_map Adds wrapper include for <unordered_map>.
cpp/common/test/includes/standard-library/unordered_set.h Adds unordered_(multi)set stubs used by tests.
cpp/common/test/includes/standard-library/unordered_set Adds wrapper include for <unordered_set>.
cpp/common/test/includes/standard-library/utility.h Expands pair constructors/templates used by tests.
cpp/common/test/includes/standard-library/valarray.h Adds std::valarray stub used by tests.
cpp/common/test/includes/standard-library/valarray Adds wrapper include for <valarray>.
cpp/common/test/includes/standard-library/variant.h Adds std::variant stub used by tests.
cpp/common/test/includes/standard-library/variant Adds wrapper include for <variant>.

Copilot's findings

  • Files reviewed: 46/48 changed files
  • Comments generated: 1

Comment on lines +49 to +53
template<typename F, typename... Args>
auto async(F&&, Args&&...) -> future<decltype(declval<F>()(declval<Args>()...))>;

template<typename F, typename... Args>
auto async(launch, F&&, Args&&...) -> future<decltype(declval<F>()(declval<Args>()...))>;
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

future.h uses declval in the async return type, but the header does not include <utility> (where std::declval is declared in these stubs) nor provide its own forward declaration. This can make the stub header ill-formed when included before <utility> (as in the new RULE-21-6-1 test). Add #include <utility> or declare declval before it is used.

Copilot uses AI. Check for mistakes.
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.

2 participants