Skip to content

Implement package expressions2 #906

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MichaelRFairhurst
Copy link
Contributor

@MichaelRFairhurst MichaelRFairhurst commented Jun 3, 2025

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-8-0-1
    • RULE-8-1-1
    • RULE-8-1-2
    • RULE-5-13-6
  • Queries have been modified for the following rules:
    • RULE-18-9 (no visible changes expected)
    • All rules involving suffixes

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 Copilot AI review requested due to automatic review settings June 3, 2025 22:06
Copy link
Contributor

@Copilot 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

This PR introduces the new “Expressions2” package by adding several MISRA-related CodeQL queries, refactoring expression support modules, and updating test headers to mock standard library facilities. Key changes include:

  • Addition of five new QLL queries enforcing MISRA rules RULE-8-1-2, RULE-8-1-1, RULE-8-0-1, and RULE-5-13-6.
  • Refactoring of Cpp14Literal and Expr modules to support integer suffix parsing and temporary-object flow steps.
  • Introduction of the Expressions2Package and updates to exclusions and rule metadata for the new queries.

Reviewed Changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cpp/misra/src/rules/RULE-8-1-2/ImplicitCapturesDisallowedInNonTransientLambda.ql New query for explicit captures in non-transient lambdas
cpp/misra/src/rules/RULE-8-1-1/NonTransientLambdaImplicitlyCapturesThis.ql New query preventing implicit this captures
cpp/misra/src/rules/RULE-8-0-1/MissingSizeofOperatorParenthesis.ql New query enforcing parentheses around sizeof
cpp/misra/src/rules/RULE-8-0-1/MissingPrecedenceClarifyingParenthesis.ql New query enforcing clarifying parentheses
cpp/misra/src/rules/RULE-5-13-6/LongLongLiteralWithSingleLSuffix.ql New query disallowing single L suffix on long long literals
cpp/common/src/codingstandards/cpp/graph/GraphPathStateSearch.qll Added stateful graph search module
cpp/common/src/codingstandards/cpp/Expr.qll Refactored expression module; extracted temporaryObjectFlowStep
cpp/common/src/codingstandards/cpp/Cpp14Literal.qll Added IntegerLiteralSuffix class and getSuffix()
cpp/common/src/codingstandards/cpp/Scope.qll Added functionDefinedInTranslationUnit predicate
cpp/common/src/codingstandards/cpp/exclusions/cpp/Expressions2.qll New autogenerated exclusions for Expressions2
cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll Imported Expressions2 in rule metadata
cpp/common/test/includes/standard-library/utility.h Provided definitions for forward overloads
cpp/common/test/includes/standard-library/functional.h Updated std::function mock constructor
Comments suppressed due to low confidence (1)

cpp/common/test/includes/standard-library/utility.h:11

  • The move function is declared but not defined. Consider providing a definition like:
template <class T>
constexpr remove_reference_t<T>&& move(T&& t) noexcept {
    return static_cast<remove_reference_t<T>&&>(t);
}
template <class T> constexpr remove_reference_t<T> &&move(T &&t) noexcept;

* instance, we could use this graph to find recursive functions, which requires knowing how an end
* node was reached from a start node (the state).
*
* Like `GraphPathSearch`, this module uses forward-reverse pruning, wihch is a pattern that is
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

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

Typo in comment: 'wihch' should be 'which'.

Suggested change
* Like `GraphPathSearch`, this module uses forward-reverse pruning, wihch is a pattern that is
* Like `GraphPathSearch`, this module uses forward-reverse pruning, which is a pattern that is

Copilot uses AI. Check for mistakes.

pragma[inline_late]
predicate functionDefinedInTranslationUnit(Function f, TranslationUnit tu) {
exists(FunctionDeclarationEntry fde | fde = f.getDefinition() |
fde = f.getDefinition() and
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

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

Duplicate predicate 'fde = f.getDefinition()' is redundant. Consider removing one of the identical checks to simplify the clause.

Suggested change
fde = f.getDefinition() and

Copilot uses AI. Check for mistakes.

@MichaelRFairhurst MichaelRFairhurst requested a review from lcartey June 4, 2025 20:55
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