Skip to content

Commit 2566ae9

Browse files
authored
Merge branch 'main' into experimental-strong-params
2 parents db5f63b + 2aaedac commit 2566ae9

68 files changed

Lines changed: 5289 additions & 2326 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/check-change-note.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- "*/ql/lib/**/*.qll"
1111
- "!**/experimental/**"
1212
- "!ql/**"
13+
- "!swift/**"
1314
- ".github/workflows/check-change-note.yml"
1415

1516
jobs:

.github/workflows/ql-for-ql-build.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ jobs:
5050
path: ${{ runner.temp }}/query-pack.zip
5151

5252
extractors:
53-
strategy:
54-
fail-fast: false
55-
5653
runs-on: ubuntu-latest
5754

5855
steps:
@@ -195,9 +192,36 @@ jobs:
195192
category: "ql-for-ql-${{ matrix.folder }}"
196193
- name: Copy sarif file to CWD
197194
run: cp ../results/ql.sarif ./${{ matrix.folder }}.sarif
195+
- name: Fixup the $scema in sarif # Until https://github.com/microsoft/sarif-vscode-extension/pull/436/ is part in a stable release
196+
run: |
197+
sed -i 's/\$schema.*/\$schema": "https:\/\/raw.githubusercontent.com\/oasis-tcs\/sarif-spec\/master\/Schemata\/sarif-schema-2.1.0",/' ${{ matrix.folder }}.sarif
198198
- name: Sarif as artifact
199199
uses: actions/upload-artifact@v3
200200
with:
201201
name: ${{ matrix.folder }}.sarif
202202
path: ${{ matrix.folder }}.sarif
203203

204+
combine:
205+
runs-on: ubuntu-latest
206+
needs:
207+
- analyze
208+
209+
steps:
210+
- uses: actions/checkout@v3
211+
- name: Make a folder for artifacts.
212+
run: mkdir -p results
213+
- name: Download all sarif files
214+
uses: actions/download-artifact@v3
215+
with:
216+
path: results
217+
- uses: actions/setup-node@v3
218+
with:
219+
node-version: 16
220+
- name: Combine all sarif files
221+
run: |
222+
node ./ql/scripts/merge-sarif.js results/**/*.sarif combined.sarif
223+
- name: Upload combined sarif file
224+
uses: actions/upload-artifact@v3
225+
with:
226+
name: combined.sarif
227+
path: combined.sarif

.github/workflows/ql-for-ql-dataset_measure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
ql/target
3737
key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
3838
- name: Build Extractor
39-
run: cd ql; env "PATH=$PATH:`dirname ${CODEQL}`" ./create-extractor-pack.sh
39+
run: cd ql; env "PATH=$PATH:`dirname ${CODEQL}`" ./scripts/create-extractor-pack.sh
4040
env:
4141
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
4242
- name: Checkout ${{ matrix.repo }}

.github/workflows/ql-for-ql-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: |
3737
cd ql;
3838
codeqlpath=$(dirname ${{ steps.find-codeql.outputs.codeql-path }});
39-
env "PATH=$PATH:$codeqlpath" ./create-extractor-pack.sh
39+
env "PATH=$PATH:$codeqlpath" ./scripts/create-extractor-pack.sh
4040
- name: Run QL tests
4141
run: |
4242
"${CODEQL}" test run --check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --search-path "${{ github.workspace }}/ql/extractor-pack" --consistency-queries ql/ql/consistency-queries ql/ql/test
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* `AnalysedExpr::isNullCheck` and `AnalysedExpr::isValidCheck` have been updated to handle variable accesses on the left-hand side of the the C++ logical and variable declarations in conditions.

cpp/ql/lib/semmle/code/cpp/controlflow/Nullness.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ predicate nullCheckExpr(Expr checkExpr, Variable var) {
4646
or
4747
exists(LogicalAndExpr op, AnalysedExpr child |
4848
expr = op and
49-
op.getRightOperand() = child and
49+
op.getAnOperand() = child and
5050
nullCheckExpr(child, v)
5151
)
5252
or
@@ -99,7 +99,7 @@ predicate validCheckExpr(Expr checkExpr, Variable var) {
9999
or
100100
exists(LogicalAndExpr op, AnalysedExpr child |
101101
expr = op and
102-
op.getRightOperand() = child and
102+
op.getAnOperand() = child and
103103
validCheckExpr(child, v)
104104
)
105105
or
@@ -169,7 +169,10 @@ class AnalysedExpr extends Expr {
169169
*/
170170
predicate isDef(LocalScopeVariable v) {
171171
this.inCondition() and
172-
this.(Assignment).getLValue() = v.getAnAccess()
172+
(
173+
this.(Assignment).getLValue() = v.getAnAccess() or
174+
this.(ConditionDeclExpr).getVariableAccess() = v.getAnAccess()
175+
)
173176
}
174177

175178
/**

cpp/ql/lib/semmle/code/cpp/exprs/Call.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,10 @@ class FunctionCall extends Call, @funbindexpr {
255255
/**
256256
* Gets the function called by this call.
257257
*
258-
* In the case of virtual function calls, the result is the most-specific function in the override tree (as
259-
* determined by the compiler) such that the target at runtime will be one of `result.getAnOverridingFunction*()`.
258+
* In the case of virtual function calls, the result is the most-specific function in the override tree
259+
* such that the target at runtime will be one of `result.getAnOverridingFunction*()`. The most-specific
260+
* function is determined by the compiler based on the compile time type of the object the function is a
261+
* member of.
260262
*/
261263
override Function getTarget() { funbind(underlyingElement(this), unresolveElement(result)) }
262264

cpp/ql/test/library-tests/controlflow/nullness/nullness.expected

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@
77
| test.cpp:15:8:15:23 | call to __builtin_expect | test.cpp:5:13:5:13 | v | is not null | is valid |
88
| test.cpp:16:8:16:23 | call to __builtin_expect | test.cpp:5:13:5:13 | v | is null | is not valid |
99
| test.cpp:17:9:17:17 | ... && ... | test.cpp:5:13:5:13 | v | is not null | is valid |
10-
| test.cpp:18:9:18:17 | ... && ... | test.cpp:5:13:5:13 | v | is not null | is not valid |
10+
| test.cpp:18:9:18:17 | ... && ... | test.cpp:5:13:5:13 | v | is not null | is valid |
1111
| test.cpp:19:9:19:18 | ... && ... | test.cpp:5:13:5:13 | v | is null | is not valid |
12-
| test.cpp:20:9:20:18 | ... && ... | test.cpp:5:13:5:13 | v | is not null | is not valid |
12+
| test.cpp:20:9:20:18 | ... && ... | test.cpp:5:13:5:13 | v | is null | is not valid |
1313
| test.cpp:21:9:21:14 | ... = ... | test.cpp:5:13:5:13 | v | is null | is not valid |
1414
| test.cpp:21:9:21:14 | ... = ... | test.cpp:7:10:7:10 | b | is not null | is valid |
15-
| test.cpp:22:17:22:17 | b | test.cpp:7:10:7:10 | b | is not null | is valid |
15+
| test.cpp:22:9:22:14 | ... = ... | test.cpp:5:13:5:13 | v | is not null | is not valid |
16+
| test.cpp:22:9:22:14 | ... = ... | test.cpp:7:13:7:13 | c | is not null | is not valid |
17+
| test.cpp:22:17:22:17 | c | test.cpp:7:13:7:13 | c | is not null | is valid |
18+
| test.cpp:23:21:23:21 | x | test.cpp:23:14:23:14 | x | is not null | is valid |
19+
| test.cpp:24:9:24:18 | (condition decl) | test.cpp:5:13:5:13 | v | is not null | is not valid |
20+
| test.cpp:24:9:24:18 | (condition decl) | test.cpp:24:14:24:14 | y | is not null | is valid |

cpp/ql/test/library-tests/controlflow/nullness/nullness.ql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import cpp
22

33
from AnalysedExpr a, LocalScopeVariable v, string isNullCheck, string isValidCheck
44
where
5-
a.getParent() instanceof IfStmt and
65
v.getAnAccess().getEnclosingStmt() = a.getParent() and
76
(if a.isNullCheck(v) then isNullCheck = "is null" else isNullCheck = "is not null") and
87
(if a.isValidCheck(v) then isValidCheck = "is valid" else isValidCheck = "is not valid")

cpp/ql/test/library-tests/controlflow/nullness/test.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ long __builtin_expect(long);
44

55
void f(int *v) {
66
int *w;
7-
bool b;
7+
bool b, c;
88

99
if (v) {}
1010
if (!v) {}
@@ -19,5 +19,7 @@ void f(int *v) {
1919
if (true && !v) {}
2020
if (!v && true) {}
2121
if (b = !v) {}
22-
if (b = !v; b) {}
22+
if (c = !v; c) {}
23+
if (int *x = v; x) {}
24+
if (int *y = v) {}
2325
}

0 commit comments

Comments
 (0)