Skip to content

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

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

mbaluda wants to merge 8 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.

Implemented Examples By Category

Category Implemented Guidelines 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 detector already handles these cases.
Refine Dir 4.6 Provide the integer-only 2025 variant while retaining the legacy numerical-type query. Floating-point declarations and aliases are excluded by the 2025 variant.
New Rule 8.18 See separate PR #1224

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.

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:
    • DIR-1-2
    • DIR-4-6
    • RULE-5-10
    • RULE-15-5
    • RULE-20-15

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.

mbaluda and others added 3 commits November 3, 2026 19:08
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This comment was marked as resolved.

mbaluda and others added 2 commits November 13, 2026 18:45
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mbaluda mbaluda mentioned this pull request Nov 18, 2026
13 of 30 tasks
mbaluda and others added 2 commits November 18, 2026 17:32
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mbaluda mbaluda mentioned this pull request Nov 18, 2026
3 of 30 tasks
@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

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 : 2828212
Mean_Predicate_Execution_Time_Ms   : 51.61347543616322
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 527.4883926392973
Total_Serialized_Execution_Time_s  : 2828.212
Mean_Query_Execution_Time_s        : 0.0516134754361632
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 145.0
Number_of_Predicates               : 54796

Release                            : 1216
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 4742424
Mean_Predicate_Execution_Time_Ms   : 61.9155819570468
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 527.0416741974722
Total_Serialized_Execution_Time_s  : 4742.424
Mean_Query_Execution_Time_s        : 0.0619155819570468
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 172.0
Number_of_Predicates               : 76595

🏁 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-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         : 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         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236
Execution_Time_Ms : 32562

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           : 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         : AlertReporting::MacroUnwrapper<Expr::Expr>::getAMacroInvocation/1#942dfbb7
Execution_Time_Ms : 26638

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             : 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-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         : 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         : 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         : 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         : 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             : 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          : 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-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         : 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         : CheckedException::CheckedException#b0aa5ec8
Execution_Time_Ms : 24106

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          : cpp
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#0b6a13dd#cpe#1236
Execution_Time_Ms : 25751

Release           : 1216
Run               : 2026-11-18_20-30-49
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236
Execution_Time_Ms : 34895

Release           : 1216
Run               : 2026-11-18_20-30-49
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : AlertReporting::MacroUnwrapper<Expr::Expr>::getAMacroInvocation/1#942dfbb7
Execution_Time_Ms : 32381

Release           : 1216
Run               : 2026-11-18_20-30-49
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 : 29967

Release           : 1216
Run               : 2026-11-18_20-30-49
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 24484

Release           : 1216
Run               : 2026-11-18_20-30-49
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : HoldsForAllCopies::HoldsForAllCopies<DeadCode::DeadOperationInstance,Expr::Expr>::RelevantElement#acaf8a9e
Execution_Time_Ms : 43387

Release           : 1216
Run               : 2026-11-18_20-30-49
Platform          : x86-linux
Language          : cpp
Suite             : misra-default
Predicate         : __Declaration::Declaration.getName/0#dispred#939ccea0__Initializer::Initializer.getDeclaration/0#dis__#join_rhs
Execution_Time_Ms : 22319

Release           : 1216
Run               : 2026-11-18_20-30-49
Platform          : x86-linux
Language          : cpp
Suite             : misra-default
Predicate         : Extensions::CPPBuiltinFunctionExtension#c159d55a
Execution_Time_Ms : 27053

Release           : 1216
Run               : 2026-11-18_20-30-49
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42
Execution_Time_Ms : 27639

Release           : 1216
Run               : 2026-11-18_20-30-49
Platform          : x86-linux
Language          : cpp
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#0b6a13dd#cpe#1236
Execution_Time_Ms : 32171

Release           : 1216
Run               : 2026-11-18_20-30-49
Platform          : x86-linux
Language          : cpp
Suite             : misra-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 28947

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