Skip to content

Commit 417d175

Browse files
committed
Merge branch 'main' into nsstring
2 parents c692a31 + 4356d35 commit 417d175

File tree

484 files changed

+58298
-12751
lines changed

Some content is hidden

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

484 files changed

+58298
-12751
lines changed

.github/actions/cache-query-compilation/action.yml

Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,83 @@ runs:
4343
codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-
4444
codeql-compile-${{ inputs.key }}-main-
4545
- name: Fill compilation cache directory
46-
id: fill-compilation-dir
47-
shell: bash
48-
run: |
49-
# Move all the existing cache into another folder, so we only preserve the cache for the current queries.
50-
node $GITHUB_WORKSPACE/.github/actions/cache-query-compilation/move-caches.js ${COMBINED_CACHE_DIR}
51-
52-
echo "compdir=${COMBINED_CACHE_DIR}" >> $GITHUB_OUTPUT
53-
env:
46+
uses: actions/github-script@v6
47+
env:
5448
COMBINED_CACHE_DIR: ${{ runner.temp }}/compilation-dir
49+
with:
50+
script: |
51+
// # Move all the existing cache into another folder, so we only preserve the cache for the current queries.
52+
// mkdir -p ${COMBINED_CACHE_DIR}
53+
// rm -f **/.cache/{lock,size} # -f to avoid errors if the cache is empty.
54+
// # copy the contents of the .cache folders into the combined cache folder.
55+
// cp -r **/.cache/* ${COMBINED_CACHE_DIR}/ || : # ignore missing files
56+
// # clean up the .cache folders
57+
// rm -rf **/.cache/*
58+
59+
const fs = require("fs");
60+
const path = require("path");
61+
62+
// the first argv is the cache folder to create.
63+
const COMBINED_CACHE_DIR = process.env.COMBINED_CACHE_DIR;
64+
65+
function* walkCaches(dir) {
66+
const files = fs.readdirSync(dir, { withFileTypes: true });
67+
for (const file of files) {
68+
if (file.isDirectory()) {
69+
const filePath = path.join(dir, file.name);
70+
yield* walkCaches(filePath);
71+
if (file.name === ".cache") {
72+
yield filePath;
73+
}
74+
}
75+
}
76+
}
77+
78+
async function copyDir(src, dest) {
79+
for await (const file of await fs.promises.readdir(src, { withFileTypes: true })) {
80+
const srcPath = path.join(src, file.name);
81+
const destPath = path.join(dest, file.name);
82+
if (file.isDirectory()) {
83+
if (!fs.existsSync(destPath)) {
84+
fs.mkdirSync(destPath);
85+
}
86+
await copyDir(srcPath, destPath);
87+
} else {
88+
await fs.promises.copyFile(srcPath, destPath);
89+
}
90+
}
91+
}
92+
93+
async function main() {
94+
const cacheDirs = [...walkCaches(".")];
95+
96+
for (const dir of cacheDirs) {
97+
console.log(`Found .cache dir at ${dir}`);
98+
}
99+
100+
// mkdir -p ${COMBINED_CACHE_DIR}
101+
fs.mkdirSync(COMBINED_CACHE_DIR, { recursive: true });
102+
103+
// rm -f **/.cache/{lock,size} # -f to avoid errors if the cache is empty.
104+
await Promise.all(
105+
cacheDirs.map((cacheDir) =>
106+
(async function () {
107+
await fs.promises.rm(path.join(cacheDir, "lock"), { force: true });
108+
await fs.promises.rm(path.join(cacheDir, "size"), { force: true });
109+
})()
110+
)
111+
);
112+
113+
// # copy the contents of the .cache folders into the combined cache folder.
114+
// cp -r **/.cache/* ${COMBINED_CACHE_DIR}/ || : # ignore missing files
115+
await Promise.all(
116+
cacheDirs.map((cacheDir) => copyDir(cacheDir, COMBINED_CACHE_DIR))
117+
);
118+
119+
// # clean up the .cache folders
120+
// rm -rf **/.cache/*
121+
await Promise.all(
122+
cacheDirs.map((cacheDir) => fs.promises.rm(cacheDir, { recursive: true }))
123+
);
124+
}
125+
main();

.github/actions/cache-query-compilation/move-caches.js

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

.github/workflows/go-tests-other-os.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
name: Test MacOS
1313
runs-on: macos-latest
1414
steps:
15-
- name: Set up Go 1.19
15+
- name: Set up Go 1.20
1616
uses: actions/setup-go@v3
1717
with:
18-
go-version: 1.19
18+
go-version: 1.20.0
1919
id: go
2020

2121
- name: Check out code
@@ -47,10 +47,10 @@ jobs:
4747
name: Test Windows
4848
runs-on: windows-latest-xl
4949
steps:
50-
- name: Set up Go 1.19
50+
- name: Set up Go 1.20
5151
uses: actions/setup-go@v3
5252
with:
53-
go-version: 1.19
53+
go-version: 1.20.0
5454
id: go
5555

5656
- name: Check out code

.github/workflows/go-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
name: Test Linux (Ubuntu)
2121
runs-on: ubuntu-latest-xl
2222
steps:
23-
- name: Set up Go 1.19
23+
- name: Set up Go 1.20
2424
uses: actions/setup-go@v3
2525
with:
26-
go-version: 1.19
26+
go-version: 1.20.0
2727
id: go
2828

2929
- name: Check out code

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ on:
55
branches: [main]
66
pull_request:
77
branches: [main]
8-
paths:
9-
- "ql/**"
10-
- "**.qll"
11-
- "**.ql"
12-
- "**.dbscheme"
13-
- "**/qlpack.yml"
14-
- ".github/workflows/ql-for-ql-build.yml"
158

169
env:
1710
CARGO_TERM_COLOR: always

cpp/autobuilder/Semmle.Autobuild.Cpp.Tests/BuildScripts.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ IEnumerable<string> IBuildActions.EnumerateDirectories(string dir)
131131

132132
bool IBuildActions.IsWindows() => IsWindows;
133133

134+
public bool IsMacOs { get; set; }
135+
136+
bool IBuildActions.IsMacOs() => IsMacOs;
137+
138+
public bool IsArm { get; set; }
139+
140+
bool IBuildActions.IsArm() => IsArm;
141+
134142
string IBuildActions.PathCombine(params string[] parts)
135143
{
136144
return string.Join(IsWindows ? '\\' : '/', parts.Where(p => !string.IsNullOrWhiteSpace(p)));

cpp/ql/lib/experimental/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll

Lines changed: 77 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -667,23 +667,78 @@ private module Stage1 implements StageSig {
667667
)
668668
or
669669
// flow into a callable
670-
exists(NodeEx arg |
671-
fwdFlow(arg, _, config) and
672-
viableParamArgEx(_, node, arg) and
673-
cc = true and
674-
not fullBarrier(node, config)
675-
)
670+
fwdFlowIn(_, _, _, node, config) and
671+
cc = true
676672
or
677673
// flow out of a callable
674+
fwdFlowOut(_, node, false, config) and
675+
cc = false
676+
or
677+
// flow through a callable
678678
exists(DataFlowCall call |
679-
fwdFlowOut(call, node, false, config) and
680-
cc = false
681-
or
682679
fwdFlowOutFromArg(call, node, config) and
683680
fwdFlowIsEntered(call, cc, config)
684681
)
685682
}
686683

684+
// inline to reduce the number of iterations
685+
pragma[inline]
686+
private predicate fwdFlowIn(
687+
DataFlowCall call, NodeEx arg, Cc cc, ParamNodeEx p, Configuration config
688+
) {
689+
// call context cannot help reduce virtual dispatch
690+
fwdFlow(arg, cc, config) and
691+
viableParamArgEx(call, p, arg) and
692+
not fullBarrier(p, config) and
693+
(
694+
cc = false
695+
or
696+
cc = true and
697+
not reducedViableImplInCallContext(call, _, _)
698+
)
699+
or
700+
// call context may help reduce virtual dispatch
701+
exists(DataFlowCallable target |
702+
fwdFlowInReducedViableImplInSomeCallContext(call, arg, p, target, config) and
703+
target = viableImplInSomeFwdFlowCallContextExt(call, config) and
704+
cc = true
705+
)
706+
}
707+
708+
/**
709+
* Holds if an argument to `call` is reached in the flow covered by `fwdFlow`.
710+
*/
711+
pragma[nomagic]
712+
private predicate fwdFlowIsEntered(DataFlowCall call, Cc cc, Configuration config) {
713+
fwdFlowIn(call, _, cc, _, config)
714+
}
715+
716+
pragma[nomagic]
717+
private predicate fwdFlowInReducedViableImplInSomeCallContext(
718+
DataFlowCall call, NodeEx arg, ParamNodeEx p, DataFlowCallable target, Configuration config
719+
) {
720+
fwdFlow(arg, true, config) and
721+
viableParamArgEx(call, p, arg) and
722+
reducedViableImplInCallContext(call, _, _) and
723+
target = p.getEnclosingCallable() and
724+
not fullBarrier(p, config)
725+
}
726+
727+
/**
728+
* Gets a viable dispatch target of `call` in the context `ctx`. This is
729+
* restricted to those `call`s for which a context might make a difference,
730+
* and to `ctx`s that are reachable in `fwdFlow`.
731+
*/
732+
pragma[nomagic]
733+
private DataFlowCallable viableImplInSomeFwdFlowCallContextExt(
734+
DataFlowCall call, Configuration config
735+
) {
736+
exists(DataFlowCall ctx |
737+
fwdFlowIsEntered(ctx, _, config) and
738+
result = viableImplInCallContextExt(call, ctx)
739+
)
740+
}
741+
687742
private predicate fwdFlow(NodeEx node, Configuration config) { fwdFlow(node, _, config) }
688743

689744
pragma[nomagic]
@@ -726,7 +781,8 @@ private module Stage1 implements StageSig {
726781
)
727782
}
728783

729-
pragma[nomagic]
784+
// inline to reduce the number of iterations
785+
pragma[inline]
730786
private predicate fwdFlowOut(DataFlowCall call, NodeEx out, Cc cc, Configuration config) {
731787
exists(ReturnPosition pos |
732788
fwdFlowReturnPosition(pos, cc, config) and
@@ -740,17 +796,6 @@ private module Stage1 implements StageSig {
740796
fwdFlowOut(call, out, true, config)
741797
}
742798

743-
/**
744-
* Holds if an argument to `call` is reached in the flow covered by `fwdFlow`.
745-
*/
746-
pragma[nomagic]
747-
private predicate fwdFlowIsEntered(DataFlowCall call, Cc cc, Configuration config) {
748-
exists(ArgNodeEx arg |
749-
fwdFlow(arg, cc, config) and
750-
viableParamArgEx(call, _, arg)
751-
)
752-
}
753-
754799
private predicate stateStepFwd(FlowState state1, FlowState state2, Configuration config) {
755800
exists(NodeEx node1 |
756801
additionalLocalStateStep(node1, state1, _, state2, config) or
@@ -817,20 +862,21 @@ private module Stage1 implements StageSig {
817862
)
818863
or
819864
// flow into a callable
820-
exists(DataFlowCall call |
821-
revFlowIn(call, node, false, config) and
822-
toReturn = false
823-
or
824-
revFlowInToReturn(call, node, config) and
825-
revFlowIsReturned(call, toReturn, config)
826-
)
865+
revFlowIn(_, node, false, config) and
866+
toReturn = false
827867
or
828868
// flow out of a callable
829869
exists(ReturnPosition pos |
830870
revFlowOut(pos, config) and
831871
node.(RetNodeEx).getReturnPosition() = pos and
832872
toReturn = true
833873
)
874+
or
875+
// flow through a callable
876+
exists(DataFlowCall call |
877+
revFlowInToReturn(call, node, config) and
878+
revFlowIsReturned(call, toReturn, config)
879+
)
834880
}
835881

836882
/**
@@ -886,11 +932,11 @@ private module Stage1 implements StageSig {
886932
additional predicate viableParamArgNodeCandFwd1(
887933
DataFlowCall call, ParamNodeEx p, ArgNodeEx arg, Configuration config
888934
) {
889-
viableParamArgEx(call, p, arg) and
890-
fwdFlow(arg, config)
935+
fwdFlowIn(call, arg, _, p, config)
891936
}
892937

893-
pragma[nomagic]
938+
// inline to reduce the number of iterations
939+
pragma[inline]
894940
private predicate revFlowIn(
895941
DataFlowCall call, ArgNodeEx arg, boolean toReturn, Configuration config
896942
) {

0 commit comments

Comments
 (0)