Skip to content

Commit ae1afef

Browse files
Merge remote-tracking branch 'origin/main' into michaelrfairhurst/implement-lanugage4-package-rule-1-5
2 parents b778360 + 2a805c0 commit ae1afef

File tree

130 files changed

+2035
-267
lines changed

Some content is hidden

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

130 files changed

+2035
-267
lines changed

.github/workflows/codeql_unit_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
file.close()
152152
153153
- name: Upload test results
154-
uses: actions/upload-artifact@v3
154+
uses: actions/upload-artifact@v4
155155
with:
156156
name: ${{ matrix.language }}-test-results-${{ runner.os }}-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library_ident }}
157157
path: |
@@ -171,7 +171,7 @@ jobs:
171171
script: |
172172
core.setFailed('Test run job failed')
173173
- name: Collect test results
174-
uses: actions/download-artifact@v3
174+
uses: actions/download-artifact@v4
175175

176176
- name: Validate test results
177177
run: |

.github/workflows/dispatch-matrix-check.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@ jobs:
2626
owner: ${{ github.repository_owner }}
2727
repositories: "codeql-coding-standards-release-engineering"
2828

29-
- name: Dispatch Matrix Testing Job
29+
- name: Invoke matrix testing job
3030
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-matrix') && steps.check-write-permission.outputs.has-permission }}
31-
uses: peter-evans/repository-dispatch@v2
32-
with:
33-
token: ${{ steps.generate-token.outputs.token }}
34-
repository: github/codeql-coding-standards-release-engineering
35-
event-type: matrix-test
36-
client-payload: '{"pr": "${{ github.event.issue.number }}"}'
31+
env:
32+
ISSUE_NR: ${{ github.event.issue.number }}
33+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
34+
run: |
35+
jq -n \
36+
--arg issue_nr "$ISSUE_NR" \
37+
'{"issue-nr": $issue_nr}' \
38+
| \
39+
gh workflow run pr-compiler-validation.yml \
40+
--json \
41+
-R github/codeql-coding-standards-release-engineering
3742
3843
- uses: actions/github-script@v6
3944
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-matrix') && steps.check-write-permission.outputs.has-permission }}

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@ jobs:
2626
owner: ${{ github.repository_owner }}
2727
repositories: "codeql-coding-standards-release-engineering"
2828

29-
- name: Dispatch Performance Testing Job
29+
- name: Invoke performance test
3030
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-performance') && steps.check-write-permission.outputs.has-permission }}
31-
uses: peter-evans/repository-dispatch@v2
32-
with:
33-
token: ${{ steps.generate-token.outputs.token }}
34-
repository: github/codeql-coding-standards-release-engineering
35-
event-type: performance-test
36-
client-payload: '{"pr": "${{ github.event.issue.number }}"}'
31+
env:
32+
ISSUE_NR: ${{ github.event.issue.number }}
33+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
34+
run: |
35+
jq -n \
36+
--arg issue_nr "$ISSUE_NR" \
37+
'{"issue-nr": $issue_nr}' \
38+
| \
39+
gh workflow run pr-performance-testing.yml \
40+
--json \
41+
-R github/codeql-coding-standards-release-engineering
3742
3843
- uses: actions/github-script@v6
3944
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-performance') && steps.check-write-permission.outputs.has-permission }}

.github/workflows/standard_library_upgrade_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ jobs:
143143
}, test_summary_file)
144144
145145
- name: Upload test results
146-
uses: actions/upload-artifact@v3
146+
uses: actions/upload-artifact@v4
147147
with:
148148
name: test-results-${{runner.os}}-${{matrix.codeql_cli}}-${{matrix.codeql_standard_library_ident}}
149149
path: |
@@ -162,7 +162,7 @@ jobs:
162162
python-version: "3.9"
163163

164164
- name: Collect test results
165-
uses: actions/download-artifact@v2
165+
uses: actions/download-artifact@v4
166166

167167
- name: Validate test results
168168
shell: python

c/cert/src/codeql-pack.lock.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.3
5+
version: 0.12.2
66
codeql/dataflow:
7+
version: 0.1.5
8+
codeql/rangeanalysis:
79
version: 0.0.4
810
codeql/ssa:
9-
version: 0.1.5
11+
version: 0.2.5
1012
codeql/tutorial:
11-
version: 0.1.5
13+
version: 0.2.5
14+
codeql/typetracking:
15+
version: 0.2.5
1216
codeql/util:
13-
version: 0.1.5
17+
version: 0.2.5
1418
compiled: false

c/cert/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ suites: codeql-suites
55
license: MIT
66
dependencies:
77
codeql/common-c-coding-standards: '*'
8-
codeql/cpp-all: 0.9.3
8+
codeql/cpp-all: 0.12.2

c/cert/test/codeql-pack.lock.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.3
5+
version: 0.12.2
66
codeql/dataflow:
7+
version: 0.1.5
8+
codeql/rangeanalysis:
79
version: 0.0.4
810
codeql/ssa:
9-
version: 0.1.5
11+
version: 0.2.5
1012
codeql/tutorial:
11-
version: 0.1.5
13+
version: 0.2.5
14+
codeql/typetracking:
15+
version: 0.2.5
1216
codeql/util:
13-
version: 0.1.5
17+
version: 0.2.5
1418
compiled: false

c/common/src/codeql-pack.lock.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.3
5+
version: 0.12.2
66
codeql/dataflow:
7+
version: 0.1.5
8+
codeql/rangeanalysis:
79
version: 0.0.4
810
codeql/ssa:
9-
version: 0.1.5
11+
version: 0.2.5
1012
codeql/tutorial:
11-
version: 0.1.5
13+
version: 0.2.5
14+
codeql/typetracking:
15+
version: 0.2.5
1216
codeql/util:
13-
version: 0.1.5
17+
version: 0.2.5
1418
compiled: false

c/common/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ version: 2.36.0-dev
33
license: MIT
44
dependencies:
55
codeql/common-cpp-coding-standards: '*'
6-
codeql/cpp-all: 0.9.3
6+
codeql/cpp-all: 0.12.2

c/common/test/codeql-pack.lock.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.3
5+
version: 0.12.2
66
codeql/dataflow:
7+
version: 0.1.5
8+
codeql/rangeanalysis:
79
version: 0.0.4
810
codeql/ssa:
9-
version: 0.1.5
11+
version: 0.2.5
1012
codeql/tutorial:
11-
version: 0.1.5
13+
version: 0.2.5
14+
codeql/typetracking:
15+
version: 0.2.5
1216
codeql/util:
13-
version: 0.1.5
17+
version: 0.2.5
1418
compiled: false

c/misra/src/codeql-pack.lock.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.3
5+
version: 0.12.2
66
codeql/dataflow:
7+
version: 0.1.5
8+
codeql/rangeanalysis:
79
version: 0.0.4
810
codeql/ssa:
9-
version: 0.1.5
11+
version: 0.2.5
1012
codeql/tutorial:
11-
version: 0.1.5
13+
version: 0.2.5
14+
codeql/typetracking:
15+
version: 0.2.5
1216
codeql/util:
13-
version: 0.1.5
17+
version: 0.2.5
1418
compiled: false

c/misra/src/codingstandards/c/misra/EssentialTypes.qll

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,17 @@ EssentialTypeCategory getEssentialTypeCategory(Type type) {
130130
essentialType.(IntegralType).isSigned() and
131131
not essentialType instanceof PlainCharType
132132
or
133+
// Anonymous enums are considered to be signed
134+
result = EssentiallySignedType() and
135+
essentialType instanceof AnonymousEnumType and
136+
not essentialType instanceof MisraBoolType
137+
or
133138
result = EssentiallyUnsignedType() and
134139
essentialType.(IntegralType).isUnsigned() and
135140
not essentialType instanceof PlainCharType
136141
or
137142
result = EssentiallyEnumType() and
138-
essentialType instanceof Enum and
143+
essentialType instanceof NamedEnumType and
139144
not essentialType instanceof MisraBoolType
140145
or
141146
result = EssentiallyFloatingType() and
@@ -348,16 +353,51 @@ class EssentialBinaryArithmeticExpr extends EssentialExpr, BinaryArithmeticOpera
348353
}
349354
}
350355

356+
/**
357+
* A named Enum type, as per D.5.
358+
*/
359+
class NamedEnumType extends Enum {
360+
NamedEnumType() {
361+
not isAnonymous()
362+
or
363+
exists(Type useOfEnum | this = useOfEnum.stripType() |
364+
exists(TypedefType t | t.getBaseType() = useOfEnum)
365+
or
366+
exists(Function f | f.getType() = useOfEnum or f.getAParameter().getType() = useOfEnum)
367+
or
368+
exists(Struct s | s.getAField().getType() = useOfEnum)
369+
or
370+
exists(Variable v | v.getType() = useOfEnum)
371+
)
372+
}
373+
}
374+
375+
/**
376+
* An anonymous Enum type, as per D.5.
377+
*/
378+
class AnonymousEnumType extends Enum {
379+
AnonymousEnumType() { not this instanceof NamedEnumType }
380+
}
381+
382+
/**
383+
* The EssentialType of an EnumConstantAccess, which may be essentially enum or essentially signed.
384+
*/
351385
class EssentialEnumConstantAccess extends EssentialExpr, EnumConstantAccess {
352-
override Type getEssentialType() { result = getTarget().getDeclaringEnum() }
386+
override Type getEssentialType() {
387+
exists(Enum e | e = getTarget().getDeclaringEnum() |
388+
if e instanceof NamedEnumType then result = e else result = stlr(this)
389+
)
390+
}
353391
}
354392

355393
class EssentialLiteral extends EssentialExpr, Literal {
356394
override Type getEssentialType() {
357395
if this instanceof BooleanLiteral
358-
then result instanceof MisraBoolType
396+
then
397+
// This returns a multitude of types - not sure if we really want that
398+
result instanceof MisraBoolType
359399
else (
360-
if this.(CharLiteral).getCharacter().length() = 1
400+
if this instanceof CharLiteral
361401
then result instanceof PlainCharType
362402
else
363403
exists(Type underlyingStandardType |

c/misra/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ license: MIT
66
default-suite-file: codeql-suites/misra-c-default.qls
77
dependencies:
88
codeql/common-c-coding-standards: '*'
9-
codeql/cpp-all: 0.9.3
9+
codeql/cpp-all: 0.12.2

c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import cpp
1616
import codingstandards.c.misra
1717
import codingstandards.c.misra.EssentialTypes
18-
import codingstandards.cpp.Bitwise
1918

2019
/**
2120
* Holds if the operator `operator` has an operand `child` that is of an inappropriate essential type
@@ -179,8 +178,7 @@ predicate isInappropriateEssentialType(
179178
child =
180179
[
181180
operator.(BinaryBitwiseOperation).getAnOperand(),
182-
operator.(Bitwise::AssignBitwiseOperation).getAnOperand(),
183-
operator.(ComplementExpr).getAnOperand()
181+
operator.(AssignBitwiseOperation).getAnOperand(), operator.(ComplementExpr).getAnOperand()
184182
] and
185183
not operator instanceof LShiftExpr and
186184
not operator instanceof RShiftExpr and

c/misra/src/rules/RULE-10-4/OperandsWithMismatchedEssentialTypeCategory.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ where
3838
// be reported as non-compliant.
3939
leftOpTypeCategory = EssentiallyEnumType() and
4040
rightOpTypeCategory = EssentiallyEnumType() and
41-
not leftOpEssentialType = rightOpEssentialType and
41+
not leftOpEssentialType.getUnspecifiedType() = rightOpEssentialType.getUnspecifiedType() and
4242
message =
4343
"The operands of this operator with usual arithmetic conversions have mismatched essentially Enum types (left operand: "
4444
+ leftOpEssentialType + ", right operand: " + rightOpEssentialType + ")."

c/misra/src/rules/RULE-11-5/ConversionFromPointerToVoidIntoPointerToObject.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import codingstandards.cpp.Pointers
1919
from Cast cast, VoidPointerType type, PointerToObjectType newType
2020
where
2121
not isExcluded(cast, Pointers1Package::conversionFromPointerToVoidIntoPointerToObjectQuery()) and
22-
type = cast.getExpr().getUnderlyingType() and
22+
type = cast.getExpr().getUnspecifiedType() and
2323
newType = cast.getUnderlyingType() and
2424
not isNullPointerConstant(cast.getExpr())
2525
select cast,

0 commit comments

Comments
 (0)