Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ImplementConversions2 rule package#946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
MichaelRFairhurst merged 25 commits intomainfromlcartey/cpp-conversions2
Oct 8, 2025

Conversation

lcartey
Copy link
Contributor

@lcarteylcartey commentedAug 18, 2025
edited by MichaelRFairhurst
Loading

Description

Follows on from#919.

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-8-2-1
    • RULE-8-2-2
    • RULE-8-2-6
    • RULE-8-2-7
    • RULE-8-2-8
    • `RULE-9-2-1
  • Queries have been modified for the following rules:
    • RULE-1-3
    • RULE-23-3
    • RULE-23-5
    • RULE-23-6

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

Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

This shared implementation will be used for implementing MISRA C++2023 8.2.1.
MISRA C++ Rule 8.2.2 is similar, but not identical.
Nested macro invocations do not have getExpandedElements(), butdo have getAffectedElements().
Detects C-style casts and functional notation casts that should bereplaced with explicit cast operators. Prevents unsafe type conversionsthat lack clear intent and proper type checking constraints. [a]
Detects casts from integral, enumerated, or void pointer types to objectpointer types that may lead to unspecified behavior. [a]
Detects casts that convert pointer types to integral types, which canmake code harder to understand and may break pointer tracking in analysistools. [a]
Detects pointer-to-integral casts that use types other thanstd::uintptr_t or std::intptr_t, which may not guarantee representationof all pointer values. [a]
Detects explicit type conversions using functional notation as standaloneexpression statements that create immediately-destroyed temporaryobjects. [a]
 - Simplify the query implementation - Improve query message
 - Remove redundant code - Use stripSpecifiers(..) to check for use of (u)intptr_t.
@lcarteylcarteyforce-pushed thelcartey/cpp-conversions2 branch from24a8098 to6e9ee92CompareAugust 26, 2025 20:45
@MichaelRFairhurst
Copy link
Collaborator

The code LGTM, however, we unfortunately have a performance issue in 8-2-2 evaluatingAlertReporting::MacroUnwrapper<NoCStyleOrFunctionalCasts::MISRACPPProhibitedCStyleCasts>::getPrimaryMacroInvocation/1#1716e261/2@f69f429.

@MichaelRFairhurst
Copy link
Collaborator

Needless to say, I'll resolve the performance issue and merge. Thank you Luke! 😢

@MichaelRFairhurst
Copy link
Collaborator

[2025-08-29 08:03:26] (4s) Starting to evaluate predicate AlertReporting::MacroUnwrapper<NoCStyleOrFunctionalCasts::MISRACPPProhibitedCStyleCasts>::getPrimaryMacroInvocation/1#1716e261/2@f69f429q[2025-08-29 08:33:27] (1804s) Tuple counts for AlertReporting::MacroUnwrapper<NoCStyleOrFunctionalCasts::MISRACPPProhibitedCStyleCasts>::getPrimaryMacroInvocation/1#1716e261/2@f69f429q after 30m1s:                      2935649      ~2%     {3} r1 = JOIN `_Location::Location.fullLocationInfo/5#dispred#cf4c85ba_Macro::MacroAccess.getLocation/0#dispred#910__#shared` WITH `AlertReporting::MacroUnwrapper<NoCStyleOrFunctionalCasts::MISRACPPProhibitedCStyleCasts>::getAMacroInvocation/1#6e2f22a3_10#join_rhs` ON FIRST 1 OUTPUT Lhs.1, Lhs.0 'result', Rhs.1 're'                      2908248      ~2%     {3}    | AND NOT `_AlertReporting::MacroUnwrapper<NoCStyleOrFunctionalCasts::MISRACPPProhibitedCStyleCasts>::getAMacro__#antijoin_rhs`(FIRST 3)                      197923826670 ~4%     {3}    | JOIN WITH `Location::Location.fullLocationInfo/5#dispred#cf4c85ba_30#join_rhs` ON FIRST 1 OUTPUT Lhs.2 're', Rhs.1, Lhs.1 'result'                      2805383      ~4%     {2}    | JOIN WITH `Element::Element.getLocation/0#dispred#6c3f5b09` ON FIRST 2 OUTPUT Lhs.0 're', Lhs.2 'result'                                           return r1

@MichaelRFairhurst
Copy link
Collaborator

/test-performance

@github-actionsGitHub 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-automationCodeQL 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 canfind full graphs and stats in the PR that was created for this test in the release engineering repo.

Release                            : v2.48.0Platform                           : x86-linuxLanguage                           : cTotal_Serialized_Execution_Time_Ms : 2460575Mean_Predicate_Execution_Time_Ms   : 45.75090178870254Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 610.2126116318541Total_Serialized_Execution_Time_s  : 2460.575Mean_Query_Execution_Time_s        : 0.0457509017887025Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 117.0Number_of_Predicates               : 53782Release                            : v2.48.0Platform                           : x86-linuxLanguage                           : cppTotal_Serialized_Execution_Time_Ms : 2837242Mean_Predicate_Execution_Time_Ms   : 56.65645592875115Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 571.6631603044997Total_Serialized_Execution_Time_s  : 2837.242Mean_Query_Execution_Time_s        : 0.0566564559287511Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 150.14999999999418Number_of_Predicates               : 50078Release                            : v2.48.0Platform                           : x86-windowsLanguage                           : cTotal_Serialized_Execution_Time_Ms : 2929819Mean_Predicate_Execution_Time_Ms   : 54.39289692559038Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 526.0522079236116Total_Serialized_Execution_Time_s  : 2929.819Mean_Query_Execution_Time_s        : 0.0543928969255903Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 166.0Number_of_Predicates               : 53864Release                            : v2.48.0Platform                           : x86-windowsLanguage                           : cppTotal_Serialized_Execution_Time_Ms : 2740161Mean_Predicate_Execution_Time_Ms   : 54.355332063794336Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 458.6002875269033Total_Serialized_Execution_Time_s  : 2740.161Mean_Query_Execution_Time_s        : 0.0543553320637943Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 167.0Number_of_Predicates               : 50412Release                            : v2.49.0Platform                           : x86-linuxLanguage                           : cTotal_Serialized_Execution_Time_Ms : 2292787Mean_Predicate_Execution_Time_Ms   : 46.19294852422686Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 447.3501657458543Total_Serialized_Execution_Time_s  : 2292.787Mean_Query_Execution_Time_s        : 0.0461929485242268Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 131.0Number_of_Predicates               : 49635Release                            : v2.49.0Platform                           : x86-linuxLanguage                           : cppTotal_Serialized_Execution_Time_Ms : 2617585Mean_Predicate_Execution_Time_Ms   : 56.77442793623251Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 496.9154104341087Total_Serialized_Execution_Time_s  : 2617.585Mean_Query_Execution_Time_s        : 0.0567744279362325Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 160.0Number_of_Predicates               : 46105Release                            : v2.49.0Platform                           : x86-windowsLanguage                           : cTotal_Serialized_Execution_Time_Ms : 3002630Mean_Predicate_Execution_Time_Ms   : 60.11030589365791Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 444.0858923209042Total_Serialized_Execution_Time_s  : 3002.63Mean_Query_Execution_Time_s        : 0.0601103058936579Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 186.0Number_of_Predicates               : 49952Release                            : v2.49.0Platform                           : x86-windowsLanguage                           : cppTotal_Serialized_Execution_Time_Ms : 3157846Mean_Predicate_Execution_Time_Ms   : 68.44646263221779Median_Predicate_Execution_Time_Ms : 1.0Standard_Deviation_Ms              : 475.591552583925Total_Serialized_Execution_Time_s  : 3157.846Mean_Query_Execution_Time_s        : 0.0684464626322177Median_Predicate_Execution_Time_s  : 0.001Percentile95_Ms                    : 214.0Number_of_Predicates               : 46136Release                            : 946Platform                           : x86-linuxLanguage                           : cppTotal_Serialized_Execution_Time_Ms : 2818237Mean_Predicate_Execution_Time_Ms   : 61.01136560443367Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 530.8007448098363Total_Serialized_Execution_Time_s  : 2818.237Mean_Query_Execution_Time_s        : 0.0610113656044336Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 166.4499999999971Number_of_Predicates               : 46192Release                            : 946Platform                           : x86-linuxLanguage                           : cTotal_Serialized_Execution_Time_Ms : 2449369Mean_Predicate_Execution_Time_Ms   : 49.16437173825773Median_Predicate_Execution_Time_Ms : 0.0Standard_Deviation_Ms              : 494.4308792508496Total_Serialized_Execution_Time_s  : 2449.369Mean_Query_Execution_Time_s        : 0.0491643717382577Median_Predicate_Execution_Time_s  : 0.0Percentile95_Ms                    : 132.0Number_of_Predicates               : 49820

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

Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : _Macro::Macro.getName/0#dispred#e28b3699_Preprocessor::PreprocessorBranchDirective#bcd2bde4#b_Prepro__#antijoin_rhsExecution_Time_Ms : 33082Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236Execution_Time_Ms : 30776Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : _Class::Class.getALinkTarget/0#dispred#29b2b38a#bf_Class::Class.getALinkTarget/0#dispred#29b2b38a#bf__#sharedExecution_Time_Ms : 29005Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-linuxLanguage          : cSuite             : cert-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12Execution_Time_Ms : 21596Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12Execution_Time_Ms : 22133Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-windowsLanguage          : cSuite             : misra-defaultPredicate         : _Class::Class.getALinkTarget/0#dispred#29b2b38a#bf_Class::Class.getALinkTarget/0#dispred#29b2b38a#bf__#sharedExecution_Time_Ms : 26536Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-windowsLanguage          : cSuite             : misra-defaultPredicate         : _Macro::Macro.getName/0#dispred#e28b3699_Preprocessor::PreprocessorBranchDirective#bcd2bde4#b_Prepro__#antijoin_rhsExecution_Time_Ms : 27098Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-windowsLanguage          : cSuite             : misra-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236Execution_Time_Ms : 25724Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-windowsLanguage          : cppSuite             : autosar-defaultPredicate         : #selectExecution_Time_Ms : 18426Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-windowsLanguage          : cppSuite             : autosar-defaultPredicate         : OrderingPredicateMustBeStrictlyWeak::IsStrictlyWeaklyOrderedComment#07390086Execution_Time_Ms : 18066Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-windowsLanguage          : cppSuite             : autosar-defaultPredicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42Execution_Time_Ms : 16505Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-windowsLanguage          : cppSuite             : autosar-defaultPredicate         : HardwareOrProtocolInterface::HardwareOrProtocolInterfaceComment#dbbd8a01Execution_Time_Ms : 18876Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : VirtualDispatchPrototype::VirtualDispatch::cannotInheritHelper/4#7c75bd87Execution_Time_Ms : 20619Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-windowsLanguage          : cSuite             : misra-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12Execution_Time_Ms : 22729Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-windowsLanguage          : cppSuite             : autosar-defaultPredicate         : Dependency::dependsOnTransitive/2#cbda84a0Execution_Time_Ms : 28181Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-windowsLanguage          : cSuite             : cert-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12Execution_Time_Ms : 19318Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : CheckedException::CheckedException#b0aa5ec8Execution_Time_Ms : 24355Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : FunctionEquivalence::typeSig/1#194ac728Execution_Time_Ms : 21744Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9Execution_Time_Ms : 26902Release           : v2.49.0Run               : 2025-08-18_14-04-37Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42Execution_Time_Ms : 30437Release           : 946Run               : 2025-08-29_23-42-00Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : CharacterOutsideTheLanguageStandardBasicSourceCharacterSetUsedInTheSourceCode::getUniversalCharacterName/1#36dbaa42Execution_Time_Ms : 27814Release           : 946Run               : 2025-08-29_23-42-00Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTable/5#79217c12Execution_Time_Ms : 23916Release           : 946Run               : 2025-08-29_23-42-00Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : _Class::Class.getALinkTarget/0#dispred#29b2b38a#bf_Class::Class.getALinkTarget/0#dispred#29b2b38a#bf__#sharedExecution_Time_Ms : 26992Release           : 946Run               : 2025-08-29_23-42-00Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : OutOfBounds::OOB::libraryFunctionNameParamTableSimpleString/5#6de8614f#cpe#1236Execution_Time_Ms : 31228Release           : 946Run               : 2025-08-29_23-42-00Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : #selectExecution_Time_Ms : 21826Release           : 946Run               : 2025-08-29_23-42-00Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : HardwareOrProtocolInterface::HardwareOrProtocolInterfaceComment#dbbd8a01Execution_Time_Ms : 22504Release           : 946Run               : 2025-08-29_23-42-00Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : CheckedException::CheckedException#b0aa5ec8Execution_Time_Ms : 26608Release           : 946Run               : 2025-08-29_23-42-00Platform          : x86-linuxLanguage          : cppSuite             : autosar-defaultPredicate         : QualifiedName::getUserTypeNameWithoutArgs/1#8cfc98e9Execution_Time_Ms : 30189Release           : 946Run               : 2025-08-29_23-42-00Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : _Macro::Macro.getName/0#dispred#e28b3699_Preprocessor::PreprocessorBranchDirective#bcd2bde4#b_Prepro__#antijoin_rhsExecution_Time_Ms : 32833Release           : 946Run               : 2025-08-29_23-42-00Platform          : x86-linuxLanguage          : cSuite             : misra-defaultPredicate         : Macro::MacroInvocation.getAnAffectedElement/0#dispred#d1462297_10#join_rhsExecution_Time_Ms : 31963

@MichaelRFairhurst
Copy link
Collaborator

Adding@knewbury01 just to verify that this performance difference looks OK, and to review my contributed performance fix0124f5e

@MichaelRFairhurst
Copy link
Collaborator

cc@jeongsoolee09 to stay in the loop regarding coding standards performance!

Copy link
Collaborator

@jeongsoolee09jeongsoolee09 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Collaborator

@MichaelRFairhurstMichaelRFairhurst left a comment

Choose a reason for hiding this comment

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

Seems I may need to approve this for GitHub's sake?

@MichaelRFairhurstMichaelRFairhurst added this pull request to themerge queueOct 8, 2025
Merged via the queue intomain with commitd268839Oct 8, 2025
25 checks passed
@MichaelRFairhurstMichaelRFairhurst deleted the lcartey/cpp-conversions2 branchOctober 8, 2025 23:04
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@MichaelRFairhurstMichaelRFairhurstMichaelRFairhurst approved these changes

@jeongsoolee09jeongsoolee09jeongsoolee09 approved these changes

@knewbury01knewbury01Awaiting requested review from knewbury01

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@lcartey@MichaelRFairhurst@jeongsoolee09

[8]ページ先頭

©2009-2025 Movatter.jp