Skip to content

MISRA C:2025: Prepare development with end-to-end examples - #1216

Open
mbaluda wants to merge 4 commits into
mainfrom
misra-c-2025-development
Open

mbaluda wants to merge 4 commits into
mainfrom
misra-c-2025-development

Conversation

@mbaluda

@mbaluda mbaluda commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This PR updates the project to support the development of MISRA C:2025 queries while retaining support for older editions.

Seven different categories of guideline changes are identified. For each category, this PR provides one complete end-to-end implementation with tests.
The remaining guideline work is tracked in rules-misra-c-2025.csv amendments.csv (changed for out-of-the box compatibility with coding-standards-team workflows).

Implemented Examples By Category

Category Implemented End-to-End Example
Renumber Rule1.2→Dir1.2 Rule21.1→Rule20.15 Rule21.2→Rule5.10
Reuse existing detectors, preserve legacy query IDs and select the appropriate identities in current/older suites. Existing product tests are reused through testref files.
Disapply Rule 15.5
Make the 2025 query Disapplied by default and support reactivation through recategorization, while preserving the legacy Advisory identity and reusing its detector/product coverage.
Clarification Rule 21.8
Extend Rule 21.8 to detect enabled assertions that call non-returning handlers such as __assert_fail, using the standard-library model. Add tests for enabled assertions, NDEBUG-disabled assertions, and unrelated non-returning calls. Existing banned-function checks remain unchanged.
Merge Rules 17.5 and 17.6
Retain Rule 17.5 array-size contract checks and remove the separate Rule 17.6 static-parameter prohibition from current suites. Older suites retain the legacy prohibition.
Expand Rule 17.3
Cover implicit declarations accepted as compiler extensions in C99 and C11. The existing test case already handles these cases.
Refine Dir 4.6 in separate PR #1225
New Rule 8.18 in separate PR #1224

Summary of the supporting changes

The supporting changes update the rule inventory, schema, generators, suites, documentation, release metadata handling, and validation scripts. Unchanged queries keep their existing standard metadata; only new or modified variants use MISRA-C-2025.

  • Suite selection: The default MISRA C suite continue to target MISRA C:2023. Separate misra-c-2025*.qls suites are added for MISRA C:2025 and exclude superseded external/misra/legacy queries (see edition-selection guide).
  • Rule metadata and release reporting: New MISRA C:2025 queries live in dedicated MISRA-C-2025 rule packages. The package generator, and release scripts recognize MISRA-C-2025 and disapplied obligations.
  • Guideline recategorization: When two editions share a rule ID, a configuration entry now applies only to queries whose default category permits the change, and supports promoting disapplied guidelines to advisory, required, or mandatory (covered by DisappliedRecategorizations.ql).

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:
    • DIR-1-2
    • RULE-5-10
    • RULE-15-5
    • RULE-20-15
  • Queries have been modified for the following rules:
    • RULE-1-2
    • RULE-15-5
    • RULE-17-6
    • RULE-21-1
    • RULE-21-2
    • RULE-21-8

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 adaptive review requested due to automatic review settings November 3, 2026 17:33

This comment was marked as resolved.

This comment was marked as resolved.

@mbaluda

mbaluda commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

/test-performance

@github-actions

Copy link
Copy Markdown

🏁 Beep Boop! Performance testing for this PR has been initiated. Please check back later for results. Note that the query package generation step must complete before testing will start so it might be a minute.

💡 If you do not hear back from me please check my status! I will report even if I fail!

@codeql-coding-standards-automation

This comment was marked as off-topic.

@mbaluda mbaluda mentioned this pull request Nov 19, 2026
13 of 30 tasks
@mbaluda
mbaluda force-pushed the misra-c-2025-development branch from 13c7992 to 26a444d Compare November 19, 2026 09:59
@mbaluda
mbaluda requested a review from a team November 19, 2026 12:18
@mbaluda mbaluda changed the title Prepare MISRA C:2025 development with end-to-end examples MISRA C:2025: Prepare development with end-to-end examples Dec 2, 2026
@mbaluda
mbaluda requested a review from knewbury01 December 2, 2026 17:10

@MichaelRFairhurst MichaelRFairhurst left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Mostly just metadata-related comments. The powershell comments have the most substance but I hope they will be simple to address.

Thank you Mauro for the amazing heavy lift of kicking this whole thing off 🙌 🙌

Comment thread c/misra/test/rules/RULE-17-3/test.c Resolved
Comment thread c/misra/test/rules/RULE-17-3/test_c99.c Resolved
mbaluda and others added 3 commits December 3, 2026 15:15
Update the MISRA C suites, example queries, and reporting for the 2025 edition while retaining older-edition support. Apply guideline recategorizations only to queries whose default category permits the transition.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep MISRA C:2023 defaults, split new rule packages, reuse shared query tests, and remove unnecessary tooling and coverage. Preserve upstream audit and strict tag standardization in both editions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mbaluda
mbaluda force-pushed the misra-c-2025-development branch from 3a2fdff to 0ba605d Compare December 3, 2026 14:47
@mbaluda

mbaluda commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks a lot @MichaelRFairhurst for the thorough review! 👍🏻

@mbaluda

mbaluda commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

/test-performance

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

🏁 Beep Boop! Performance testing for this PR has been initiated. Please check back later for results. Note that the query package generation step must complete before testing will start so it might be a minute.

💡 If you do not hear back from me please check my status! I will report even if I fail!

@codeql-coding-standards-automation

Copy link
Copy Markdown

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


Release                            : v2.62.0
Platform                           : x86-windows
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 4958885
Mean_Predicate_Execution_Time_Ms   : 69.36085545640194
Median_Predicate_Execution_Time_Ms : 1.0
Standard_Deviation_Ms              : 468.2069608070895
Total_Serialized_Execution_Time_s  : 4958.885
Mean_Query_Execution_Time_s        : 0.0693608554564019
Median_Predicate_Execution_Time_s  : 0.001
Percentile95_Ms                    : 218.0
Number_of_Predicates               : 71494

Release                            : v2.62.0
Platform                           : x86-windows
Language                           : c
Total_Serialized_Execution_Time_Ms : 3809287
Mean_Predicate_Execution_Time_Ms   : 74.47432012356057
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 607.469703694893
Total_Serialized_Execution_Time_s  : 3809.287
Mean_Query_Execution_Time_s        : 0.0744743201235605
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 196.0
Number_of_Predicates               : 51149

Release                            : v2.62.0
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 4355006
Mean_Predicate_Execution_Time_Ms   : 61.04492507814581
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 537.0863746976181
Total_Serialized_Execution_Time_s  : 4355.006
Mean_Query_Execution_Time_s        : 0.0610449250781458
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 165.0
Number_of_Predicates               : 71341

Release                            : v2.62.0
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2655267
Mean_Predicate_Execution_Time_Ms   : 51.8738546896673
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 558.1246726024739
Total_Serialized_Execution_Time_s  : 2655.267
Mean_Query_Execution_Time_s        : 0.0518738546896673
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 138.0
Number_of_Predicates               : 51187

Release                            : v2.63.0
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2381234
Mean_Predicate_Execution_Time_Ms   : 43.47777027150395
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 393.4527978004665
Total_Serialized_Execution_Time_s  : 2381.234
Mean_Query_Execution_Time_s        : 0.0434777702715039
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 128.59999999999854
Number_of_Predicates               : 54769

Release                            : v2.63.0
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 4065701
Mean_Predicate_Execution_Time_Ms   : 53.32416551905043
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 442.8881913986132
Total_Serialized_Execution_Time_s  : 4065.701
Mean_Query_Execution_Time_s        : 0.0533241655190504
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 157.0
Number_of_Predicates               : 76245

Release                            : v2.63.0
Platform                           : x86-windows
Language                           : c
Total_Serialized_Execution_Time_Ms : 3034882
Mean_Predicate_Execution_Time_Ms   : 55.37398507489919
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 455.29066671984685
Total_Serialized_Execution_Time_s  : 3034.882
Mean_Query_Execution_Time_s        : 0.0553739850748991
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 167.0
Number_of_Predicates               : 54807

Release                            : v2.63.0
Platform                           : x86-windows
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 5513135
Mean_Predicate_Execution_Time_Ms   : 72.29961706926849
Median_Predicate_Execution_Time_Ms : 1.0
Standard_Deviation_Ms              : 583.3310319459151
Total_Serialized_Execution_Time_s  : 5513.135
Mean_Query_Execution_Time_s        : 0.0722996170692684
Median_Predicate_Execution_Time_s  : 0.001
Percentile95_Ms                    : 211.0
Number_of_Predicates               : 76254

Release                            : 1216
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2606943
Mean_Predicate_Execution_Time_Ms   : 47.61626696378016
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 526.0372657521964
Total_Serialized_Execution_Time_s  : 2606.943
Mean_Query_Execution_Time_s        : 0.0476162669637801
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 128.0
Number_of_Predicates               : 54749

Release                            : 1216
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 4274346
Mean_Predicate_Execution_Time_Ms   : 56.0195279223077
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 474.7537206185938
Total_Serialized_Execution_Time_s  : 4274.346
Mean_Query_Execution_Time_s        : 0.0560195279223077
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 168.0
Number_of_Predicates               : 76301

🏁 Below are the slowest predicates for the last 2 releases vs this PR.


Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-linux
Language          : cpp
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#0b6a13dd#cpe#1236
Execution_Time_Ms : 25751

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : _Macro::Macro.getName/0#dispred#e28b3699_Preprocessor::PreprocessorBranchDirective#bcd2bde4#b_Prepro__#antijoin_rhs
Execution_Time_Ms : 21209

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12
Execution_Time_Ms : 22222

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : AlertReporting::MacroUnwrapper<Expr::Expr>::getAMacroInvocation/1#942dfbb7
Execution_Time_Ms : 26638

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : _Macro::Macro.getName/0#dispred#e28b3699_Preprocessor::PreprocessorBranchDirective#bcd2bde4#b_Prepro__#antijoin_rhs
Execution_Time_Ms : 30524

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : HoldsForAllCopies::HoldsForAllCopies<DeadCode::DeadOperationInstance,Expr::Expr>::RelevantElement#acaf8a9e
Execution_Time_Ms : 34196

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236
Execution_Time_Ms : 32562

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : CheckedException::CheckedException#b0aa5ec8
Execution_Time_Ms : 33528

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : HardwareOrProtocolInterface::HardwareOrProtocolInterfaceComment#dbbd8a01
Execution_Time_Ms : 33310

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 33143

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42
Execution_Time_Ms : 32779

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : CommentedOutCode::CommentBlock.getLine/1#dispred#d32fa3dd
Execution_Time_Ms : 32236

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236
Execution_Time_Ms : 23382

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-linux
Language          : c
Suite             : cert-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12
Execution_Time_Ms : 21225

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CheckedException::CheckedException#b0aa5ec8
Execution_Time_Ms : 24106

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : HoldsForAllCopies::HoldsForAllCopies<DeadCode::DeadOperationInstance,Expr::Expr>::RelevantElement#acaf8a9e
Execution_Time_Ms : 26750

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-linux
Language          : cpp
Suite             : misra-default
Predicate         : AlertReporting::MacroUnwrapper<Expr::Expr>::getAMacroInvocation/1#942dfbb7
Execution_Time_Ms : 25716

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42
Execution_Time_Ms : 25413

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-linux
Language          : c
Suite             : cert-default
Predicate         : InitializationFunctions::typeSig/1#132168f1
Execution_Time_Ms : 17161

Release           : v2.63.0
Run               : 2026-11-13_19-16-40
Platform          : x86-linux
Language          : cpp
Suite             : misra-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 21423

Release           : 1216
Run               : 2026-12-04_11-23-05
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236
Execution_Time_Ms : 35288

Release           : 1216
Run               : 2026-12-04_11-23-05
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : HoldsForAllCopies::HoldsForAllCopies<DeadCode::DeadOperationInstance,Expr::Expr>::RelevantElement#acaf8a9e
Execution_Time_Ms : 42155

Release           : 1216
Run               : 2026-12-04_11-23-05
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : _Macro::Macro.getName/0#dispred#e28b3699_Preprocessor::PreprocessorBranchDirective#bcd2bde4#b_Prepro__#antijoin_rhs
Execution_Time_Ms : 33400

Release           : 1216
Run               : 2026-12-04_11-23-05
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : AlertReporting::MacroUnwrapper<Expr::Expr>::getAMacroInvocation/1#942dfbb7
Execution_Time_Ms : 31233

Release           : 1216
Run               : 2026-12-04_11-23-05
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : Dependency::dependsOnTransitive/2#cbda84a0
Execution_Time_Ms : 27178

Release           : 1216
Run               : 2026-12-04_11-23-05
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CommentedOutCode::CommentBlock.getLine/1#dispred#d32fa3dd
Execution_Time_Ms : 25729

Release           : 1216
Run               : 2026-12-04_11-23-05
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CheckedException::CheckedException#b0aa5ec8
Execution_Time_Ms : 26190

Release           : 1216
Run               : 2026-12-04_11-23-05
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42
Execution_Time_Ms : 32072

Release           : 1216
Run               : 2026-12-04_11-23-05
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : #select
Execution_Time_Ms : 26278

Release           : 1216
Run               : 2026-12-04_11-23-05
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : PlainNumericalTypeUsedOverExplicitTypedef::forbiddenRealType/2#88244e11
Execution_Time_Ms : 29586

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants