Skip to content

Commit 50333b2

Browse files
authored
Merge branch 'main' into mbaluda-next-merge
2 parents 782f8b0 + a98c55c commit 50333b2

27 files changed

Lines changed: 581 additions & 30 deletions

.github/actions/install-codeql-packs/action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ inputs:
77
The path to the CodeQL CLI directory.
88
required: false
99

10+
common_caches:
11+
description: |
12+
The path to the CodeQL common caches directory.
13+
required: false
14+
1015
mode:
1116
description: |
1217
The `--mode` option to `codeql pack install`.
@@ -22,4 +27,6 @@ runs:
2227
CODEQL_CLI: ${{ inputs.cli_path }}
2328
run: |
2429
PATH=$PATH:$CODEQL_CLI
25-
python scripts/install-packs.py --mode ${{ inputs.mode }}
30+
python scripts/install-packs.py \
31+
--mode ${{ inputs.mode }} \
32+
--common-caches "${{ inputs.common_caches }}"

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

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ env:
2020
XARGS_MAX_PROCS: 4
2121

2222
jobs:
23-
2423
prepare-code-scanning-pack-matrix:
2524
name: Prepare CodeQL Code Scanning pack matrix
2625
runs-on: ubuntu-22.04
@@ -62,10 +61,19 @@ jobs:
6261
codeql-home: ${{ github.workspace }}/codeql_home
6362
add-to-path: false
6463

64+
- name: Cache queries compilation
65+
id: cache-queries-compilation
66+
uses: actions/cache/restore@v6
67+
with:
68+
path: ${{ github.workspace }}/codeql_cache
69+
key: ${{ runner.os }}-codeql-compilation-code-scanning-pack-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library }}-${{ github.run_id }}
70+
restore-keys: ${{ runner.os }}-codeql-compilation-code-scanning-pack-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library }}
71+
6572
- name: Install CodeQL packs
6673
uses: ./.github/actions/install-codeql-packs
6774
with:
6875
cli_path: ${{ github.workspace }}/codeql_home/codeql
76+
common_caches: ${{ github.workspace }}/codeql_cache
6977

7078
- name: Determine ref for external help files
7179
id: determine-ref
@@ -105,11 +113,22 @@ jobs:
105113
PATH=$PATH:$CODEQL_HOME/codeql
106114
# Precompile all queries, and use a compilation cache larger than default
107115
# to ensure we cache all the queries for later steps
108-
codeql query compile --precompile --threads 0 --compilation-cache-size=1024 cpp c
116+
codeql query compile \
117+
--common-caches=${{ github.workspace }}/codeql_cache \
118+
--precompile \
119+
--threads 0 \
120+
--compilation-cache-size=1024 \
121+
cpp c
109122
110123
cd ..
111124
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
112125
126+
- name: Save queries compilation cache
127+
uses: actions/cache/save@v6
128+
with:
129+
path: ${{ github.workspace }}/codeql_cache
130+
key: ${{ steps.cache-queries-compilation.outputs.cache-primary-key }}
131+
113132
- name: Upload GHAS Query Pack
114133
uses: actions/upload-artifact@v7
115134
with:
@@ -119,20 +138,21 @@ jobs:
119138
- name: Create qlpack bundles
120139
env:
121140
CODEQL_HOME: ${{ github.workspace }}/codeql_home
141+
CODEQL_CACHE: ${{ github.workspace }}/codeql_cache
122142
run: |
123143
PATH=$PATH:$CODEQL_HOME/codeql
124144
125-
codeql pack bundle --output=common-cpp-coding-standards.tgz cpp/common/src
126-
codeql pack bundle --output=common-c-coding-standards.tgz c/common/src
127-
codeql pack bundle --output=misra-c-coding-standards.tgz c/misra/src
128-
codeql pack bundle --output=cert-c-coding-standards.tgz c/cert/src
129-
codeql pack bundle --output=cert-cpp-coding-standards.tgz cpp/cert/src
130-
codeql pack bundle --output=autosar-cpp-coding-standards.tgz cpp/autosar/src
131-
codeql pack bundle --output=misra-cpp-coding-standards.tgz cpp/misra/src
132-
codeql pack bundle --output=report-coding-standards.tgz cpp/report/src
145+
codeql pack bundle --common-caches="$CODEQL_CACHE" --output=common-cpp-coding-standards.tgz cpp/common/src
146+
codeql pack bundle --common-caches="$CODEQL_CACHE" --output=common-c-coding-standards.tgz c/common/src
147+
codeql pack bundle --common-caches="$CODEQL_CACHE" --output=misra-c-coding-standards.tgz c/misra/src
148+
codeql pack bundle --common-caches="$CODEQL_CACHE" --output=cert-c-coding-standards.tgz c/cert/src
149+
codeql pack bundle --common-caches="$CODEQL_CACHE" --output=cert-cpp-coding-standards.tgz cpp/cert/src
150+
codeql pack bundle --common-caches="$CODEQL_CACHE" --output=autosar-cpp-coding-standards.tgz cpp/autosar/src
151+
codeql pack bundle --common-caches="$CODEQL_CACHE" --output=misra-cpp-coding-standards.tgz cpp/misra/src
152+
codeql pack bundle --common-caches="$CODEQL_CACHE" --output=report-coding-standards.tgz cpp/report/src
133153
134154
- name: Upload qlpack bundles
135155
uses: actions/upload-artifact@v7
136156
with:
137157
name: coding-standards-codeql-packs
138-
path: '*-coding-standards.tgz'
158+
path: "*-coding-standards.tgz"

.github/workflows/codeql_unit_tests.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ on:
1717
- "rc/**"
1818

1919
jobs:
20-
2120
prepare-unit-test-matrix:
2221
name: Prepare CodeQL unit test matrix
2322
runs-on: ubuntu-22.04
@@ -59,7 +58,7 @@ jobs:
5958

6059
- name: Cache CodeQL
6160
id: cache-codeql
62-
uses: actions/cache@v5
61+
uses: actions/cache@v6
6362
with:
6463
# A list of files, directories, and wildcard patterns to cache and restore
6564
path: ${{github.workspace}}/codeql_home
@@ -75,16 +74,34 @@ jobs:
7574
codeql-home: ${{ github.workspace }}/codeql_home
7675
add-to-path: false
7776

77+
- name: Cache queries compilation
78+
id: cache-queries-compilation
79+
uses: actions/cache/restore@v6
80+
with:
81+
path: ${{ github.workspace }}/codeql_cache
82+
key: ${{ runner.os }}-codeql-compilation-${{ matrix.language }}-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library_ident }}-${{ github.run_id }}
83+
restore-keys: ${{ runner.os }}-codeql-compilation-${{ matrix.language }}-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library_ident }}
84+
7885
- name: Install CodeQL packs
7986
uses: ./.github/actions/install-codeql-packs
8087
with:
8188
cli_path: ${{ github.workspace }}/codeql_home/codeql
89+
common_caches: ${{ github.workspace }}/codeql_cache
8290

8391
- name: Pre-Compile Queries
8492
id: pre-compile-queries
8593
run: |
86-
${{ github.workspace }}/codeql_home/codeql/codeql query compile --threads 0 ${{ matrix.language }}
87-
94+
${{ github.workspace }}/codeql_home/codeql/codeql query compile \
95+
--common-caches=${{ github.workspace }}/codeql_cache \
96+
--compilation-cache-size=1024 \
97+
--threads 0 \
98+
${{ matrix.language }}
99+
100+
- name: Save queries compilation cache
101+
uses: actions/cache/save@v6
102+
with:
103+
path: ${{ github.workspace }}/codeql_cache
104+
key: ${{ steps.cache-queries-compilation.outputs.cache-primary-key }}
88105

89106
- name: Run test suites
90107
id: run-test-suites
@@ -135,7 +152,7 @@ jobs:
135152
os.makedirs(os.path.dirname(test_report_path), exist_ok=True)
136153
test_report_file = open(test_report_path, 'w')
137154
files_to_close.append(test_report_file)
138-
procs.append(subprocess.Popen([codeql_bin, "test", "run", "--failing-exitcode=122", f"--slice={slice}/{num_slices}", "--ram=2048", "--format=json", *test_roots], stdout=test_report_file, stderr=subprocess.PIPE))
155+
procs.append(subprocess.Popen([codeql_bin, "test", "run", "--common-caches=${{ github.workspace }}/codeql_cache", "--failing-exitcode=122", f"--slice={slice}/{num_slices}", "--ram=2048", "--format=json", *test_roots], stdout=test_report_file, stderr=subprocess.PIPE))
139156
140157
for p in procs:
141158
_, err = p.communicate()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
- `A0-1-3`, `RULE-0-2-4` - `UnusedLocalFunction.ql`:
2+
- Fixed false positives for private pure virtual functions used through the non-virtual
3+
interface (NVI) idiom. `DynamicCallGraph::getTarget()` resolves a virtual call to the
4+
implementations that may actually run; a pure virtual function has no body, so it is
5+
never a viable dispatch target and was reported as unused even when a sibling member
6+
called it. A call is now also counted when the function is the statically named
7+
callee. Pure virtual functions that are genuinely never called and never overridden
8+
are still reported.
9+
- Excluded private member functions of class templates that are never concretely
10+
instantiated anywhere in the database (and where no sibling member of the same
11+
class-template pattern is instantiated either). Clang never elaborates a body for the
12+
members of such patterns, so calls between sibling members of the same
13+
never-instantiated class (e.g. a public entry point calling a private helper) cannot be
14+
resolved by the call graph. This is common for generic "plumbing" library code
15+
(CRTP-style wrappers, etc.) that is only ever
16+
instantiated by downstream consumers outside of the analyzed codebase.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `RULE-5-10-1` - `PoorlyFormedIdentifier.ql`:
2+
- Avoid false positives for none user defined identifiers like __PRETTY_FUNCTION__
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `RULE-10-0-1`, `M8-0-1` - `MultipleLocalDeclarators.qll`:
2+
- Added a check to ignore structured bindings from C++17, which are explicitly allowed by RULE 10-0-1 and serve a unique useful purpose.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- `RULE-7-0-1` - `NoConversionFromBool.ql`:
2+
- Fixed false positives where a `bool` value is bound to a reference whose
3+
referenced type is also `bool` (e.g. `bool&`, `const bool&`), including
4+
when this happens via a generic/forwarding-reference parameter (e.g.
5+
`template<class T> void f(T&& t)`, or class template forwarding
6+
constructors such as `std::pair`'s `pair(U1&&, U2&&)`) that happens to be
7+
instantiated with `bool`. Binding a value to a reference of its own type
8+
does not change the type or representation of the value, so this is not
9+
a conversion from `bool` in the sense intended by the rule.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- `RULE-7-0-4` - `InappropriateBitwiseOrShiftOperands.ql`:
2+
- Fixes #1177 - the rule no longer reports operands whose type is not a MISRA numeric type. The
3+
operand checks used `not isUnsignedType(operandType)`, which is vacuously true for every type
4+
that has no MISRA numeric type at all, such as class types and the unresolved dependent types
5+
of uninstantiated template bodies. As a result the rule reported operations that do not use
6+
the built-in operators, most notably the stream insertion and extraction operators. The checks
7+
now use `isSignedType(operandType)` instead.
8+
- Operands of character type, of a non-standard integral type, and of an unscoped enumeration
9+
type without a fixed underlying type are consequently no longer reported, because none of them
10+
has a MISRA numeric type. Unscoped enumerations without a fixed underlying type are covered by
11+
`RULE-10-2-3`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- `RULE-5-10-1` - `PoorlyFormedIdentifier.ql`:
2+
- Fixed false positives where a local variable or function parameter was reported as
3+
"defined in reserved namespace" merely because its enclosing function is the body of
4+
an explicit template specialization that C++ permits users to add to namespace `std`
5+
(for example, `std::hash<UserType>::operator()`'s parameter and local names).
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
- `RULE-7-0-2` - `NoImplicitBoolConversion.ql`:
2+
- Fixed false positives where a conversion's source expression type could
3+
not be resolved to a concrete type (`UnknownType`), which occurs only in
4+
template-dependent contexts that the extractor cannot resolve, e.g. a
5+
`constexpr bool` variable template whose initializer is itself another
6+
dependent variable template such as `std::conjunction_v<...>`.
7+
- Fixed false positives on reference-dereference conversions (`bool&`/
8+
`bool&&` to `bool`), which occur e.g. via the compiler-synthesized
9+
`std::get<N>(...)` call used to implement structured binding
10+
decomposition (`auto [a, b] = some_pair_or_tuple_expr;` where `b` is
11+
`bool`). Dereferencing a reference to `bool` does not change the type or
12+
representation of the value, so this is not a conversion to `bool` in
13+
the sense intended by the rule.

0 commit comments

Comments
 (0)