Skip to content

Commit ce6c326

Browse files
Merge remote-tracking branch 'origin/main' into michaelrfairhurst/package-dead-code-7
2 parents a4a9186 + b0e343f commit ce6c326

File tree

28 files changed

+206
-152
lines changed

28 files changed

+206
-152
lines changed

.github/workflows/code-scanning-pack-gen.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
zip -r codeql-coding-standards/code-scanning-cpp-query-pack.zip codeql-coding-standards/c/ codeql-coding-standards/cpp/ codeql-coding-standards/.codeqlmanifest.json codeql-coding-standards/supported_codeql_configs.json codeql-coding-standards/scripts/configuration codeql-coding-standards/scripts/reports codeql-coding-standards/scripts/shared codeql-coding-standards/scripts/guideline_recategorization codeql-coding-standards/schemas
112112
113113
- name: Upload GHAS Query Pack
114-
uses: actions/upload-artifact@v5
114+
uses: actions/upload-artifact@v6
115115
with:
116116
name: code-scanning-cpp-query-pack.zip
117117
path: code-scanning-cpp-query-pack.zip
@@ -132,7 +132,7 @@ jobs:
132132
codeql pack bundle --output=report-coding-standards.tgz cpp/report/src
133133
134134
- name: Upload qlpack bundles
135-
uses: actions/upload-artifact@v5
135+
uses: actions/upload-artifact@v6
136136
with:
137137
name: coding-standards-codeql-packs
138138
path: '*-coding-standards.tgz'

.github/workflows/codeql_unit_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ jobs:
153153
file.close()
154154
155155
- name: Upload test results
156-
uses: actions/upload-artifact@v5
156+
uses: actions/upload-artifact@v6
157157
with:
158158
name: ${{ matrix.language }}-test-results-${{ runner.os }}-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library_ident }}
159159
path: |
@@ -173,7 +173,7 @@ jobs:
173173
script: |
174174
core.setFailed('Test run job failed')
175175
- name: Collect test results
176-
uses: actions/download-artifact@v6
176+
uses: actions/download-artifact@v7
177177

178178
- name: Validate test results
179179
run: |

.github/workflows/extra-rule-validation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ jobs:
4646
run: scripts/util/Test-SharedImplementationsHaveTestCases.ps1 -Language c -CIMode
4747

4848

49-
- uses: actions/upload-artifact@v5
49+
- uses: actions/upload-artifact@v6
5050
if: failure()
5151
with:
5252
name: missing-test-report.csv
5353
path: MissingTestReport*.csv
5454

55-
- uses: actions/upload-artifact@v5
55+
- uses: actions/upload-artifact@v6
5656
if: failure()
5757
with:
5858
name: test-report.csv

.github/workflows/generate-html-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
python scripts/documentation/generate_iso26262_docs.py coding-standards-html-docs
3838
3939
- name: Upload HTML documentation
40-
uses: actions/upload-artifact@v5
40+
uses: actions/upload-artifact@v6
4141
with:
4242
name: coding-standards-docs-${{ github.sha }}
4343
path: coding-standards-html-docs/

.github/workflows/standard_library_upgrade_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ jobs:
145145
}, test_summary_file)
146146
147147
- name: Upload test results
148-
uses: actions/upload-artifact@v5
148+
uses: actions/upload-artifact@v6
149149
with:
150150
name: test-results-${{runner.os}}-${{matrix.codeql_cli}}-${{matrix.codeql_standard_library_ident}}
151151
path: |
@@ -164,7 +164,7 @@ jobs:
164164
python-version: "3.9"
165165

166166
- name: Collect test results
167-
uses: actions/download-artifact@v6
167+
uses: actions/download-artifact@v7
168168

169169
- name: Validate test results
170170
shell: python
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A0-1-2` - `UnusedReturnValue.ql`:
2+
- Refactors the rule implementation into a shared library for usage in MISRA C++ ruleset. No externally visible changes expected.

cpp/autosar/src/rules/A0-1-2/UnusedReturnValue.ql

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,10 @@
1616

1717
import cpp
1818
import codingstandards.cpp.autosar
19-
import codingstandards.cpp.Operator
20-
import cpp
19+
import codingstandards.cpp.rules.unusedreturnvalueshared.UnusedReturnValueShared
2120

22-
/*
23-
* This query performs a simple syntactic check to ensure that the return value of the function is
24-
* not completely ignored. This matches the examples given in the rule, although the text itself is
25-
* not entirely clear. This means it will not find cases where something is done with the return
26-
* value, but it is not meaningfully read. For example: `int ret_val = f();`, with no subsequent
27-
* access of `ret_val`. However, such a case _would_ be flagged by A0-1-1 - Useless assignment.
28-
*/
21+
module UnusedReturnValueConfig implements UnusedReturnValueSharedConfigSig {
22+
Query getQuery() { result = DeadCodePackage::unusedReturnValueQuery() }
23+
}
2924

30-
from FunctionCall fc, Function f
31-
where
32-
not isExcluded(fc, DeadCodePackage::unusedReturnValueQuery()) and
33-
// Find function calls in `ExprStmt`s, which indicate the return value is ignored
34-
fc.getParent() instanceof ExprStmt and
35-
// Ignore calls to void functions, which don't return values
36-
not fc.getUnderlyingType() instanceof VoidType and
37-
// Get the function target
38-
f = fc.getTarget() and
39-
// Overloaded (i.e. user defined) operators should behave in the same way as built-in operators,
40-
// so the rule does not require the use of the return value
41-
not f instanceof Operator and
42-
// Exclude cases where the function call is generated within a macro, as the user of the macro is
43-
// not necessarily able to address those results
44-
not fc.isAffectedByMacro() and
45-
// Rule allows disabling this rule where a static_cast<void> or a C-style cast to void is applied
46-
not exists(Cast cast | cast instanceof StaticCast or cast instanceof CStyleCast |
47-
fc.getExplicitlyConverted() = cast and
48-
cast.getActualType() instanceof VoidType
49-
)
50-
select fc, "Return value from call to $@ is unused.", f, f.getName()
25+
import UnusedReturnValueShared<UnusedReturnValueConfig>

cpp/autosar/test/rules/A0-1-2/UnusedReturnValue.expected

Lines changed: 0 additions & 1 deletion
This file was deleted.

cpp/autosar/test/rules/A0-1-2/UnusedReturnValue.qlref

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cpp/common/test/rules/unusedreturnvalueshared/UnusedReturnValueShared.ql

0 commit comments

Comments
 (0)