Skip to content

Commit d25ef97

Browse files
Merge branch 'main' into jeongsoolee09/MISRA-C++-2023-Memory5-Memory6
2 parents 1a9f0a1 + d20c643 commit d25ef97

File tree

75 files changed

+2972
-278
lines changed

Some content is hidden

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

75 files changed

+2972
-278
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

c/misra/src/rules/RULE-18-9/ArrayToPointerConversionOfTemporaryObject.ql

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import cpp
1717
import codingstandards.c.misra
1818
import codingstandards.c.Objects
19+
import codingstandards.cpp.Expr
1920

2021
/**
2122
* Holds if the value of an expression is used or stored.
@@ -37,32 +38,14 @@ predicate isUsedOrStored(Expr e) {
3738
e = any(ClassAggregateLiteral l).getAFieldExpr(_)
3839
}
3940

40-
/**
41-
* Find expressions that defer their value directly to an inner expression
42-
* value.
43-
*
44-
* When an array is on the rhs of a comma expr, or in the then/else branch of a
45-
* ternary expr, and the result us used as a pointer, then the ArrayToPointer
46-
* conversion is marked inside comma expr/ternary expr, on the operands. These
47-
* conversions are only non-compliant if they flow into an operation or store.
48-
*
49-
* Full flow analysis with localFlowStep should not be necessary, and may cast a
50-
* wider net than needed for some queries, potentially resulting in false
51-
* positives.
52-
*/
53-
Expr temporaryObjectFlowStep(Expr e) {
54-
e = result.(CommaExpr).getRightOperand()
55-
or
56-
e = result.(ConditionalExpr).getThen()
57-
or
58-
e = result.(ConditionalExpr).getElse()
59-
}
60-
6141
from FieldAccess fa, TemporaryObjectIdentity temporary, ArrayToPointerConversion conversion
6242
where
6343
not isExcluded(conversion, InvalidMemory3Package::arrayToPointerConversionOfTemporaryObjectQuery()) and
6444
fa = temporary.getASubobjectAccess() and
6545
conversion.getExpr() = fa and
66-
isUsedOrStored(temporaryObjectFlowStep*(conversion.getExpr()))
46+
exists(Expr useOrStore |
47+
temporaryObjectFlowStep*(conversion.getExpr(), useOrStore) and
48+
isUsedOrStored(useOrStore)
49+
)
6750
select conversion, "Array to pointer conversion of array $@ from temporary object $@.",
6851
fa.getTarget(), fa.getTarget().getName(), temporary, temporary.toString()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- All queries related to integer suffixes:
2+
- No visible changes expected: the regex for parsing integer suffixes, and how they are treated after lexing, has been refactored.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `RULE-18-9` - `ArraytoPointerConversionOfTemporaryObject.ql`
2+
- The behavior for finding flow steps of temporary objects (for example, from ternary branches to the ternary expr result) has been extracted for reuse in other rules, no visible changes expected.
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.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- `A3-3-2` - `StaticOrThreadLocalObjectsNonConstantInit`:
2+
- The checks for non-constant initialization have been moved to be usable in other queries, such as MISRA C++23 Rule 6.7.2.
3+
- No visible changes in query results expected.

0 commit comments

Comments
 (0)