Skip to content

DIR-4-10: Report include guards reused across header files - #1230

Draft
mbaluda wants to merge 1 commit into
misra-c-2025-developmentfrom
mbaluda/dir-4-10-unique-guards
Draft

mbaluda wants to merge 1 commit into
misra-c-2025-developmentfrom
mbaluda/dir-4-10-unique-guards

Conversation

@mbaluda

@mbaluda mbaluda commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Description

MISRA C:2025 changes Dir 4.10 so that the uniqueness requirement for include-guard names is now normative.

This PR updates the shared IncludeGuardsNotUsed check so that it reports header files that share an include-guard name, even when the headers have different extensions or are included only from separate translation units.

The new check applies to every MISRA C edition, because MISRA C:2012 already had the same intent.

Affected queries

All queries using the shared IncludeGuardsNotUsed library can now report new results:

  • c/misra/precaution-include-guards-not-provided (MISRA C Dir 4.10)
  • cpp/autosar/include-guards-not-provided (AUTOSAR M16-2-3)
  • cpp/misra/no-valid-ifdef-guard-in-header (MISRA C++:2023 Rule 19.2.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 number here
  • Queries have been modified for the following rules:
    • DIR-4-10
    • M16-2-3
    • RULE-19-2-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!)

MISRA C:2025 promotes the guard-uniqueness note of Dir 4.10 to a
normative amplification. Report header files sharing an include-guard
name, even across translation units or file extensions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mbaluda
mbaluda changed the base branch from main to misra-c-2025-development November 26, 2026 14:42
@mbaluda

mbaluda commented Nov 26, 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                            : 1230
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2519700
Mean_Predicate_Execution_Time_Ms   : 45.98496185713764
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 523.4588490748166
Total_Serialized_Execution_Time_s  : 2519.7
Mean_Query_Execution_Time_s        : 0.0459849618571376
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 126.0
Number_of_Predicates               : 54794

Release                            : 1230
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 4476898
Mean_Predicate_Execution_Time_Ms   : 58.75733991311538
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 490.1443749558294
Total_Serialized_Execution_Time_s  : 4476.898
Mean_Query_Execution_Time_s        : 0.0587573399131153
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 167.0
Number_of_Predicates               : 76193

🏁 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         : 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         : 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         : _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-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          : 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          : 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         : 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             : autosar-default
Predicate         : CheckedException::CheckedException#b0aa5ec8
Execution_Time_Ms : 24106

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-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-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         : CommentedOutCode::CommentBlock.getLine/1#dispred#d32fa3dd
Execution_Time_Ms : 32236

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         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42
Execution_Time_Ms : 32779

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-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-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          : c
Suite             : misra-default
Predicate         : _Macro::Macro.getName/0#dispred#e28b3699_Preprocessor::PreprocessorBranchDirective#bcd2bde4#b_Prepro__#antijoin_rhs
Execution_Time_Ms : 21209

Release           : 1230
Run               : 2026-11-26_14-59-53
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 27730

Release           : 1230
Run               : 2026-11-26_14-59-53
Platform          : x86-linux
Language          : cpp
Suite             : misra-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 28697

Release           : 1230
Run               : 2026-11-26_14-59-53
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 : 38486

Release           : 1230
Run               : 2026-11-26_14-59-53
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : HoldsForAllCopies::HoldsForAllCopies<DeadCode::DeadOperationInstance,Expr::Expr>::RelevantElement#acaf8a9e
Execution_Time_Ms : 33193

Release           : 1230
Run               : 2026-11-26_14-59-53
Platform          : x86-linux
Language          : cpp
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#0b6a13dd#cpe#1236
Execution_Time_Ms : 28585

Release           : 1230
Run               : 2026-11-26_14-59-53
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236
Execution_Time_Ms : 40076

Release           : 1230
Run               : 2026-11-26_14-59-53
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12
Execution_Time_Ms : 30131

Release           : 1230
Run               : 2026-11-26_14-59-53
Platform          : x86-linux
Language          : cpp
Suite             : misra-default
Predicate         : AlertReporting::MacroUnwrapper<Expr::Expr>::getAMacroInvocation/1#942dfbb7
Execution_Time_Ms : 25700

Release           : 1230
Run               : 2026-11-26_14-59-53
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 : 22479

Release           : 1230
Run               : 2026-11-26_14-59-53
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42
Execution_Time_Ms : 25905

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