Skip to content

Commit 34ecd57

Browse files
committed
Merge branch 'main' into knewbury01/cpp-misra2023-declarations5
2 parents 17f18cc + 0c087a6 commit 34ecd57

90 files changed

Lines changed: 2639 additions & 336 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codeql_unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ jobs:
168168
steps:
169169
- name: Check if run-test-suites job failed to complete, if so fail
170170
if: ${{ needs.run-test-suites.result == 'failure' }}
171-
uses: actions/github-script@v8
171+
uses: actions/github-script@v9
172172
with:
173173
script: |
174174
core.setFailed('Test run job failed')

.github/workflows/dispatch-matrix-test-on-comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
--json \
4545
-R github/codeql-coding-standards-release-engineering
4646
47-
- uses: actions/github-script@v8
47+
- uses: actions/github-script@v9
4848
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-matrix') && steps.check-write-permission.outputs.has-permission }}
4949
with:
5050
script: |

.github/workflows/dispatch-release-performance-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
--json \
4545
-R github/codeql-coding-standards-release-engineering
4646
47-
- uses: actions/github-script@v8
47+
- uses: actions/github-script@v9
4848
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-performance') && steps.check-write-permission.outputs.has-permission }}
4949
with:
5050
script: |

.github/workflows/upgrade_codeql_dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
find c \( -name '*.ql' -or -name '*.qll' \) -print0 | xargs -0 --max-procs "$XARGS_MAX_PROCS" codeql query format --in-place
5757
5858
- name: Create Pull Request
59-
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
59+
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
6060
with:
6161
title: "Upgrade `github/codeql` dependency to ${{ github.event.inputs.codeql_cli_version }}"
6262
body: |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- `A9-6-2` - `BitFieldsShallBeUsedOnlyWhenInterfacingToHardwareOrConformingToCommunicationProtocols.ql`:
2+
- Shorten the name to `BitFieldsShouldNotBeDeclaredAutosarCpp`, where the name shared query it imports is `BitFieldsShouldNotBeDeclared`.
3+
- Tag `"portability"` is added.
4+
- Alert message now includes single quotes around union name.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- All queries related to side effects:
2+
- Compound assignments of pointer parameters (e.g. `p += 1`) are no longer treated as a modification of the pointed-to object. This was previously only handled for simple assignments (e.g. `p = ...`).

cpp/autosar/src/rules/A9-5-1/UnionsUsed.ql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @id cpp/autosar/unions-used
33
* @name A9-5-1: Unions shall not be used
4-
* @description Unions shall not be used. Tagged untions can be used if std::variant is not
4+
* @description Unions shall not be used. Tagged unions can be used if 'std::variant' is not
55
* available.
66
* @kind problem
77
* @precision very-high
@@ -34,8 +34,9 @@ class TaggedUnion extends UserType {
3434
}
3535
}
3636

37-
from Union u
37+
from Union u, string message
3838
where
3939
not isExcluded(u, BannedSyntaxPackage::unionsUsedQuery()) and
40-
not u.getParentScope() instanceof TaggedUnion
41-
select u, u.getName() + " is not a tagged union."
40+
not u.getParentScope() instanceof TaggedUnion and
41+
message = "'" + u.getName() + "' is not a tagged union."
42+
select u, message

cpp/autosar/src/rules/A9-6-2/BitFieldsShallBeUsedOnlyWhenInterfacingToHardwareOrConformingToCommunicationProtocols.ql

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @id cpp/autosar/bit-fields-should-not-be-declared-autosar-cpp
3+
* @name A9-6-2: Bit-fields shall be used only when interfacing to hardware or conforming to communication protocols
4+
* @description The usage of bit-fields increases code complexity and certain aspects of bit-field
5+
* manipulation can be error prone and implementation defined. Hence a bit-field usage
6+
* is reserved only when interfacing to hardware or conformance to communication
7+
* protocols.
8+
* @kind problem
9+
* @precision very-high
10+
* @problem.severity recommendation
11+
* @tags external/autosar/id/a9-6-2
12+
* maintainability
13+
* portability
14+
* external/autosar/allocated-target/design
15+
* external/autosar/enforcement/partially-automated
16+
* external/autosar/obligation/required
17+
*/
18+
19+
import cpp
20+
import codingstandards.cpp.autosar
21+
import codingstandards.cpp.rules.bitfieldsshouldnotbedeclared.BitFieldsShouldNotBeDeclared
22+
23+
module BitFieldsShouldNotBeDeclaredAutosarCppConfig implements BitFieldsShouldNotBeDeclaredConfigSig
24+
{
25+
Query getQuery() { result = RepresentationPackage::bitFieldsShouldNotBeDeclaredAutosarCppQuery() }
26+
}
27+
28+
import BitFieldsShouldNotBeDeclared<BitFieldsShouldNotBeDeclaredAutosarCppConfig>

cpp/autosar/src/rules/M3-1-2/FunctionsDeclaredAtBlockScope.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
import cpp
1919
import codingstandards.cpp.autosar
20+
import codingstandards.cpp.rules.functiondeclaredatblockscope.FunctionDeclaredAtBlockScope
2021

21-
from DeclStmt decl, Function f
22-
where
23-
not isExcluded(decl, DeclarationsPackage::functionsDeclaredAtBlockScopeQuery()) and
24-
not isExcluded(f, DeclarationsPackage::functionsDeclaredAtBlockScopeQuery()) and
25-
decl.getADeclaration() = f
26-
select f, "Function " + f.getName() + " is declared at block scope."
22+
module FunctionDeclaredAtBlockScopeConfig implements FunctionDeclaredAtBlockScopeConfigSig {
23+
Query getQuery() { result = DeclarationsPackage::functionsDeclaredAtBlockScopeQuery() }
24+
}
25+
26+
import FunctionDeclaredAtBlockScope<FunctionDeclaredAtBlockScopeConfig>

0 commit comments

Comments
 (0)