Skip to content

First implementation of Rule 22-3-1#986

Open
MichaelRFairhurst wants to merge 7 commits intomainfrom
michaelrfairhurst/preconditions-rule-22-3-1-no-asserts-on-constants
Open

First implementation of Rule 22-3-1#986
MichaelRFairhurst wants to merge 7 commits intomainfrom
michaelrfairhurst/preconditions-rule-22-3-1-no-asserts-on-constants

Conversation

@MichaelRFairhurst
Copy link
Collaborator

Description

please enter the description of your change here

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:
    • rule number here

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

@MichaelRFairhurst
Copy link
Collaborator Author

/test-performance

@github-actions
Copy link

🏁 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

🏁 Beep Boop! One or things failed during performance testing. Please check the release engineering repo for details.

@MichaelRFairhurst
Copy link
Collaborator Author

Looks like performance testing & compiler compatibility testing can't handle the qtil dependency.

@MichaelRFairhurst
Copy link
Collaborator Author

/test-performance

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

🏁 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

🏁 Beep Boop! One or things failed during performance testing. Please check the release engineering repo for details.

@MichaelRFairhurst
Copy link
Collaborator Author

/test-performance

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

🏁 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

🏁 Beep Boop! One or things failed during performance testing. Please check the release engineering repo for details.

@MichaelRFairhurst
Copy link
Collaborator Author

/test-performance

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

🏁 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

🏁 Beep Boop! One or things failed during performance testing. Please check the release engineering repo for details.

@MichaelRFairhurst
Copy link
Collaborator Author

/test-performance

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

🏁 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

🏁 Beep Boop! One or things failed during performance testing. Please check the release engineering repo for details.

@MichaelRFairhurst
Copy link
Collaborator Author

/test-performance

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

🏁 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

🏁 Beep Boop! One or things failed during performance testing. Please check the release engineering repo for details.

@MichaelRFairhurst
Copy link
Collaborator Author

/test-performance

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

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

@MichaelRFairhurst
Copy link
Collaborator Author

/test-performance

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

🏁 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

🏁 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.53.0
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2333626
Mean_Predicate_Execution_Time_Ms   : 46.86466512702079
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 464.3841141059346
Total_Serialized_Execution_Time_s  : 2333.626
Mean_Query_Execution_Time_s        : 0.0468646651270207
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 129.0
Number_of_Predicates               : 49795

Release                            : v2.53.0
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 2709046
Mean_Predicate_Execution_Time_Ms   : 58.63989783107494
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 538.09393160794
Total_Serialized_Execution_Time_s  : 2709.046
Mean_Query_Execution_Time_s        : 0.0586398978310749
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 157.0
Number_of_Predicates               : 46198

Release                            : v2.53.0
Platform                           : x86-windows
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 2854906
Mean_Predicate_Execution_Time_Ms   : 61.82528098403967
Median_Predicate_Execution_Time_Ms : 1.0
Standard_Deviation_Ms              : 415.5458433646134
Total_Serialized_Execution_Time_s  : 2854.906
Mean_Query_Execution_Time_s        : 0.0618252809840396
Median_Predicate_Execution_Time_s  : 0.001
Percentile95_Ms                    : 197.0
Number_of_Predicates               : 46177

Release                            : v2.53.0
Platform                           : x86-windows
Language                           : c
Total_Serialized_Execution_Time_Ms : 2749208
Mean_Predicate_Execution_Time_Ms   : 55.15846073592552
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 416.7448594682875
Total_Serialized_Execution_Time_s  : 2749.208
Mean_Query_Execution_Time_s        : 0.0551584607359255
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 178.9499999999971
Number_of_Predicates               : 49842

Release                            : v2.54.0
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2430395
Mean_Predicate_Execution_Time_Ms   : 48.376659567268455
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 494.4557213724258
Total_Serialized_Execution_Time_s  : 2430.395
Mean_Query_Execution_Time_s        : 0.0483766595672684
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 125.09999999999854
Number_of_Predicates               : 50239

Release                            : v2.54.0
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 2756233
Mean_Predicate_Execution_Time_Ms   : 59.12125697125697
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 526.333362805237
Total_Serialized_Execution_Time_s  : 2756.233
Mean_Query_Execution_Time_s        : 0.0591212569712569
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 157.0
Number_of_Predicates               : 46620

Release                            : v2.54.0
Platform                           : x86-windows
Language                           : c
Total_Serialized_Execution_Time_Ms : 2926320
Mean_Predicate_Execution_Time_Ms   : 57.99171637502229
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 461.2110774874936
Total_Serialized_Execution_Time_s  : 2926.32
Mean_Query_Execution_Time_s        : 0.0579917163750222
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 180.0
Number_of_Predicates               : 50461

Release                            : v2.54.0
Platform                           : x86-windows
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 3096680
Mean_Predicate_Execution_Time_Ms   : 66.35979856423444
Median_Predicate_Execution_Time_Ms : 1.0
Standard_Deviation_Ms              : 423.5921363539812
Total_Serialized_Execution_Time_s  : 3096.68
Mean_Query_Execution_Time_s        : 0.0663597985642344
Median_Predicate_Execution_Time_s  : 0.001
Percentile95_Ms                    : 203.0
Number_of_Predicates               : 46665

Release                            : 986
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2446036
Mean_Predicate_Execution_Time_Ms   : 48.27003986265146
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 499.650467268476
Total_Serialized_Execution_Time_s  : 2446.036
Mean_Query_Execution_Time_s        : 0.0482700398626514
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 128.0
Number_of_Predicates               : 50674

Release                            : 986
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 2861637
Mean_Predicate_Execution_Time_Ms   : 60.85352472089314
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 533.9278600177122
Total_Serialized_Execution_Time_s  : 2861.637
Mean_Query_Execution_Time_s        : 0.0608535247208931
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 157.79999999999563
Number_of_Predicates               : 47025

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


Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42
Execution_Time_Ms : 15807

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 16113

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : FunctionEquivalence::typeSig/1#194ac728
Execution_Time_Ms : 26442

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : Dependency::dependsOnTransitive/2#cbda84a0
Execution_Time_Ms : 19625

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236
Execution_Time_Ms : 33193

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CheckedException::CheckedException#b0aa5ec8
Execution_Time_Ms : 26887

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : Dependency::dependsOnTransitive/2#cbda84a0
Execution_Time_Ms : 26305

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : #select
Execution_Time_Ms : 22092

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236
Execution_Time_Ms : 30138

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : Macro::MacroInvocation.getAnAffectedElement/0#dispred#d1462297_10#join_rhs
Execution_Time_Ms : 33782

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : FunctionEquivalence::typeSig/1#194ac728#bf
Execution_Time_Ms : 14027

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 28849

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42
Execution_Time_Ms : 32616

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
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 : 27240

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : _Class::Class.getALinkTarget/0#dispred#29b2b38a#bf_Class::Class.getALinkTarget/0#dispred#29b2b38a#bf__#shared
Execution_Time_Ms : 26026

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12
Execution_Time_Ms : 21202

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 25179

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : Macro::MacroInvocation.getAnAffectedElement/0#dispred#d1462297_10#join_rhs
Execution_Time_Ms : 31405

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : _Class::Class.getALinkTarget/0#dispred#29b2b38a#bf_Class::Class.getALinkTarget/0#dispred#29b2b38a#bf__#shared
Execution_Time_Ms : 24575

Release           : v2.54.0
Run               : 2026-01-27_17-28-56
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 : 28686

Release           : 986
Run               : 2026-03-05_18-51-38
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 25431

Release           : 986
Run               : 2026-03-05_18-51-38
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236
Execution_Time_Ms : 33695

Release           : 986
Run               : 2026-03-05_18-51-38
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 : 27351

Release           : 986
Run               : 2026-03-05_18-51-38
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : Macro::MacroInvocation.getAnAffectedElement/0#dispred#d1462297_10#join_rhs
Execution_Time_Ms : 34768

Release           : 986
Run               : 2026-03-05_18-51-38
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : _Class::Class.getALinkTarget/0#dispred#29b2b38a#bf_Class::Class.getALinkTarget/0#dispred#29b2b38a#bf__#shared
Execution_Time_Ms : 25851

Release           : 986
Run               : 2026-03-05_18-51-38
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : HardwareOrProtocolInterface::HardwareOrProtocolInterfaceComment#dbbd8a01
Execution_Time_Ms : 23344

Release           : 986
Run               : 2026-03-05_18-51-38
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CheckedException::CheckedException#b0aa5ec8
Execution_Time_Ms : 26336

Release           : 986
Run               : 2026-03-05_18-51-38
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 29348

Release           : 986
Run               : 2026-03-05_18-51-38
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42
Execution_Time_Ms : 29161

Release           : 986
Run               : 2026-03-05_18-51-38
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : Dependency::dependsOnTransitive/2#cbda84a0
Execution_Time_Ms : 24431

@MichaelRFairhurst
Copy link
Collaborator Author

/test-performance

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

🏁 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

🏁 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.54.0
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2430395
Mean_Predicate_Execution_Time_Ms   : 48.376659567268455
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 494.4557213724258
Total_Serialized_Execution_Time_s  : 2430.395
Mean_Query_Execution_Time_s        : 0.0483766595672684
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 125.09999999999854
Number_of_Predicates               : 50239

Release                            : v2.54.0
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 2756233
Mean_Predicate_Execution_Time_Ms   : 59.12125697125697
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 526.333362805237
Total_Serialized_Execution_Time_s  : 2756.233
Mean_Query_Execution_Time_s        : 0.0591212569712569
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 157.0
Number_of_Predicates               : 46620

Release                            : v2.54.0
Platform                           : x86-windows
Language                           : c
Total_Serialized_Execution_Time_Ms : 2926320
Mean_Predicate_Execution_Time_Ms   : 57.99171637502229
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 461.2110774874936
Total_Serialized_Execution_Time_s  : 2926.32
Mean_Query_Execution_Time_s        : 0.0579917163750222
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 180.0
Number_of_Predicates               : 50461

Release                            : v2.54.0
Platform                           : x86-windows
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 3096680
Mean_Predicate_Execution_Time_Ms   : 66.35979856423444
Median_Predicate_Execution_Time_Ms : 1.0
Standard_Deviation_Ms              : 423.5921363539812
Total_Serialized_Execution_Time_s  : 3096.68
Mean_Query_Execution_Time_s        : 0.0663597985642344
Median_Predicate_Execution_Time_s  : 0.001
Percentile95_Ms                    : 203.0
Number_of_Predicates               : 46665

Release                            : v2.55.0
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2462123
Mean_Predicate_Execution_Time_Ms   : 48.59804985887136
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 502.2058253197624
Total_Serialized_Execution_Time_s  : 2462.123
Mean_Query_Execution_Time_s        : 0.0485980498588713
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 131.0
Number_of_Predicates               : 50663

Release                            : v2.55.0
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 2834919
Mean_Predicate_Execution_Time_Ms   : 60.34824165531335
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 529.769276782814
Total_Serialized_Execution_Time_s  : 2834.919
Mean_Query_Execution_Time_s        : 0.0603482416553133
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 161.0
Number_of_Predicates               : 46976

Release                            : v2.55.0
Platform                           : x86-windows
Language                           : c
Total_Serialized_Execution_Time_Ms : 2874242
Mean_Predicate_Execution_Time_Ms   : 56.78861162152016
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 458.3911504793912
Total_Serialized_Execution_Time_s  : 2874.242
Mean_Query_Execution_Time_s        : 0.0567886116215201
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 172.0
Number_of_Predicates               : 50613

Release                            : v2.55.0
Platform                           : x86-windows
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 3264372
Mean_Predicate_Execution_Time_Ms   : 69.20294248584936
Median_Predicate_Execution_Time_Ms : 1.0
Standard_Deviation_Ms              : 422.8561248913159
Total_Serialized_Execution_Time_s  : 3264.372
Mean_Query_Execution_Time_s        : 0.0692029424858493
Median_Predicate_Execution_Time_s  : 0.001
Percentile95_Ms                    : 232.0
Number_of_Predicates               : 47171

Release                            : 986
Platform                           : x86-linux
Language                           : c
Total_Serialized_Execution_Time_Ms : 2449165
Mean_Predicate_Execution_Time_Ms   : 48.42543894337235
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 491.3888340559884
Total_Serialized_Execution_Time_s  : 2449.165
Mean_Query_Execution_Time_s        : 0.0484254389433723
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 132.0
Number_of_Predicates               : 50576

Release                            : 986
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 2766673
Mean_Predicate_Execution_Time_Ms   : 58.81782813895149
Median_Predicate_Execution_Time_Ms : 0.0
Standard_Deviation_Ms              : 509.34593838101966
Total_Serialized_Execution_Time_s  : 2766.673
Mean_Query_Execution_Time_s        : 0.0588178281389514
Median_Predicate_Execution_Time_s  : 0.0
Percentile95_Ms                    : 163.0
Number_of_Predicates               : 47038

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


Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : Macro::MacroInvocation.getAnAffectedElement/0#dispred#d1462297_10#join_rhs
Execution_Time_Ms : 30299

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12
Execution_Time_Ms : 30308

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : _Class::Class.getALinkTarget/0#dispred#29b2b38a#bf_Class::Class.getALinkTarget/0#dispred#29b2b38a#bf__#shared
Execution_Time_Ms : 26763

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-windows
Language          : c
Suite             : misra-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 15349

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : _Class::Class.getALinkTarget/0#dispred#29b2b38a#bf_Class::Class.getALinkTarget/0#dispred#29b2b38a#bf__#shared
Execution_Time_Ms : 26610

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
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 : 28003

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : Macro::MacroInvocation.getAnAffectedElement/0#dispred#d1462297_10#join_rhs
Execution_Time_Ms : 33661

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236
Execution_Time_Ms : 34006

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 16772

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : Dependency::dependsOnTransitive/2#cbda84a0
Execution_Time_Ms : 19502

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
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 : 37589

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : FunctionEquivalence::typeSig/1#194ac728#bf
Execution_Time_Ms : 14694

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CheckedException::CheckedException#b0aa5ec8
Execution_Time_Ms : 25410

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 27871

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : HardwareOrProtocolInterface::HardwareOrProtocolInterfaceComment#dbbd8a01
Execution_Time_Ms : 22167

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : FunctionEquivalence::typeSig/1#194ac728
Execution_Time_Ms : 23164

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42
Execution_Time_Ms : 30550

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : _Call::Call.getArgument/1#dispred#ada436ba_Call::Call.getArgument/1#dispred#ada436ba_120#join_rhs_El__#shared
Execution_Time_Ms : 14268

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-windows
Language          : cpp
Suite             : autosar-default
Predicate         : FunctionEquivalence::typeSig/1#194ac728
Execution_Time_Ms : 26534

Release           : v2.55.0
Run               : 2026-03-06_19-22-39
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 24349

Release           : 986
Run               : 2026-03-06_23-52-11
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : Macro::MacroInvocation.getAnAffectedElement/0#dispred#d1462297_10#join_rhs
Execution_Time_Ms : 34179

Release           : 986
Run               : 2026-03-06_23-52-11
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 : 34381

Release           : 986
Run               : 2026-03-06_23-52-11
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42
Execution_Time_Ms : 28065

Release           : 986
Run               : 2026-03-06_23-52-11
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 28423

Release           : 986
Run               : 2026-03-06_23-52-11
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : HardwareOrProtocolInterface::HardwareOrProtocolInterfaceComment#dbbd8a01
Execution_Time_Ms : 20955

Release           : 986
Run               : 2026-03-06_23-52-11
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : CheckedException::CheckedException#b0aa5ec8
Execution_Time_Ms : 25172

Release           : 986
Run               : 2026-03-06_23-52-11
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : _Class::Class.getALinkTarget/0#dispred#29b2b38a#bf_Class::Class.getALinkTarget/0#dispred#29b2b38a#bf__#shared
Execution_Time_Ms : 25460

Release           : 986
Run               : 2026-03-06_23-52-11
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236
Execution_Time_Ms : 32634

Release           : 986
Run               : 2026-03-06_23-52-11
Platform          : x86-linux
Language          : c
Suite             : misra-default
Predicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9
Execution_Time_Ms : 23581

Release           : 986
Run               : 2026-03-06_23-52-11
Platform          : x86-linux
Language          : cpp
Suite             : autosar-default
Predicate         : VirtualDispatchPrototype::VirtualDispatch::cannotInheritHelper/4#7c75bd87
Execution_Time_Ms : 24346

@MichaelRFairhurst
Copy link
Collaborator Author

MichaelRFairhurst commented Mar 7, 2026

To summarize the performance results:

Release                            : 986
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 2766673
Release                            : v2.55.0
Platform                           : x86-linux
Language                           : cpp
Total_Serialized_Execution_Time_Ms : 2834919

Worth noting, it can (probably*) only have gone down via random variation, it did not change existing code.

The previous run (that compared only to 2.54) was also slower, at 2861637 total serialized execution time.

* it might have affected magic in shared predicates in some weirdly positive way but that seems highly unlikely

@MichaelRFairhurst MichaelRFairhurst marked this pull request as ready for review March 7, 2026 03:08
Copilot AI review requested due to automatic review settings March 7, 2026 03:08
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

Implements the first CodeQL check for MISRA C++:2023 RULE-22-3-1 by detecting assert(...) calls whose condition is a constant expression, and adds shared infrastructure to model/assert macro expansions robustly across different implementations.

Changes:

  • Add a new MISRA rule query (AssertMacroUsedWithAConstantExpression) with unit tests and rule package metadata.
  • Introduce a shared Assert standard-library modeling library (plus small AST helper modules) to extract the asserted condition from macro-expanded forms.
  • Add advanced-security/qtil as a dependency of the common C++ pack and update pack lockfiles accordingly.

Reviewed changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
rules.csv Assign RULE-22-3-1 to the new Preconditions3 rule package.
rule_packages/cpp/Preconditions3.json Add rule package metadata for RULE-22-3-1 and its query.
cpp/misra/src/rules/RULE-22-3-1/AssertMacroUsedWithAConstantExpression.ql New rule query reporting assert with constant-expression conditions.
cpp/misra/test/rules/RULE-22-3-1/test.cpp Unit tests for compliant/non-compliant assert usages.
cpp/misra/test/rules/RULE-22-3-1/AssertMacroUsedWithAConstantExpression.qlref Wire test directory to the production query.
cpp/misra/test/rules/RULE-22-3-1/AssertMacroUsedWithAConstantExpression.expected Expected results for the new MISRA rule test.
cpp/common/src/codingstandards/cpp/standardlibrary/Assert.qll New shared library to model assert macro invocations and recover asserted conditions.
cpp/common/src/codingstandards/cpp/ast/Conditions.qll New helper abstraction for “conditional evaluation” nodes.
cpp/common/src/codingstandards/cpp/ast/Search.qll New helper to find the outermost matching AST node (uses qtil).
cpp/common/test/library/codingstandards/cpp/standardlibrary/Assert/test.cpp Library-level tests covering multiple assert macro expansion patterns.
cpp/common/test/library/codingstandards/cpp/standardlibrary/Assert/AssertTest.ql Inline expectations test runner for the Assert library.
cpp/common/test/library/codingstandards/cpp/standardlibrary/Assert/AssertTest.expected Empty expected output for inline expectations test (mismatches would be emitted).
cpp/common/test/includes/standard-library/assert.h Make the test assert macro expand to a conditional + abort, enabling macro-expansion modeling.
cpp/common/src/codingstandards/cpp/exclusions/cpp/Preconditions3.qll Add autogenerated exclusions metadata module for the new package/query.
cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll Register the new Preconditions3 package in query metadata plumbing.
cpp/common/src/qlpack.yml Add advanced-security/qtil dependency to common C++ pack.
cpp/common/src/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil.
cpp/common/test/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil.
cpp/autosar/src/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil.
cpp/autosar/test/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil.
cpp/cert/src/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil.
cpp/cert/test/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil.
cpp/misra/src/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil.
c/common/src/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil (transitively via common-cpp).
c/common/test/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil (transitively via common-cpp).
c/misra/src/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil (transitively via common-cpp).
c/misra/test/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil (transitively via common-cpp).
c/cert/src/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil (transitively via common-cpp).
c/cert/test/codeql-pack.lock.yml Lockfile update to include advanced-security/qtil (transitively via common-cpp).
Comments suppressed due to low confidence (1)

cpp/misra/test/rules/RULE-22-3-1/test.cpp:87

  • These assertions assume an ASCII-like character set ('a' == 97, 'A' < 'Z'), which is not guaranteed by the language and can make the test fail on alternative encodings. Use encoding-independent constant-expressions instead (for example 'a' == 'a' and 'A' != 'Z') and update the .expected values accordingly.
  assert('a' == 97); // NON_COMPLIANT
  assert('A' < 'Z'); // NON_COMPLIANT

license: MIT
dependencies:
codeql/cpp-all: 5.0.0
advanced-security/qtil: "0.0.3"
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

This PR adds a new external CodeQL pack dependency (advanced-security/qtil) to the released codeql/common-cpp-coding-standards pack. Per the developer handbook’s change note policy, changes that affect the structure/layout of release artifacts typically require a change note. Please confirm whether a change_notes/ entry is needed for this dependency addition and add one if so.

Suggested change
advanced-security/qtil: "0.0.3"

Copilot uses AI. Check for mistakes.
}

void test_assert_with_constant_expression() {
assert(sizeof(int) == 4); // NON_COMPLIANT
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The test assumes sizeof(int) == 4 evaluates to true and the .expected file hard-codes the constant value as 1. This makes the test brittle on non-ILP32/LP64 targets (or if the extractor target differs). Prefer a target-independent constant-expression (for example sizeof(char) == 1, or another expression guaranteed true/false across platforms) and update the .expected accordingly; also update the other sizeof(int) == ... occurrences in this file for consistency.

This issue also appears on line 86 of the same file.

Copilot uses AI. Check for mistakes.
* condition being asserted.
*
* For example, `assert(x)` may expand to `{ if (!__unlikely(x)) abort(); }`. In this case:
* - We first identify the "outermost conditonal" generated by the macro, which is the `if`
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

Typo in comment: "conditonal" should be "conditional".

Suggested change
* - We first identify the "outermost conditonal" generated by the macro, which is the `if`
* - We first identify the "outermost conditional" generated by the macro, which is the `if`

Copilot uses AI. Check for mistakes.
Comment on lines +106 to +107
* For example, `x || abort();` appears to assert `x` is true, while `if (!x) abort();`
* appears to assert `x` is false.
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The example in this doc comment is logically inverted: in if (!x) abort(); the assertion is effectively that x is true (since the program aborts when !x is true). Please adjust the wording so it matches what appearsToAssert returns and avoid confusing future readers.

Suggested change
* For example, `x || abort();` appears to assert `x` is true, while `if (!x) abort();`
* appears to assert `x` is false.
* For example, both `x || abort();` and `if (!x) abort();` effectively assert that `x`
* is true (in the second case, by asserting that `!x` is false).

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +35
#define assert(X) \
{ __builtin_expect((X), 1) ? (void)0 : __assert (#X, __FILE__, __LINE__); }

Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

This file redefines the assert macro multiple times with different replacement lists but never #undefs it in between. Many compilers emit diagnostics for this, and it’s undefined/ill-formed in some modes. Add #undef assert before each subsequent #define assert(...) (similar to how other tests handle redefining assert).

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