Skip to content

Commit 2047954

Browse files
authored
Merge branch 'main' into patch-1
2 parents ff9a724 + 861a368 commit 2047954

File tree

673 files changed

+64298
-51379
lines changed

Some content is hidden

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

673 files changed

+64298
-51379
lines changed

.devcontainer/swift/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.236.0/containers/cpp/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Debian / Ubuntu version (use Debian 11, Ubuntu 18.04/22.04 on local arm64/Apple Silicon): debian-11, debian-10, ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
4+
FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-ubuntu-22.04
5+
6+
USER root
7+
ADD root.sh /tmp/root.sh
8+
ADD update-codeql.sh /usr/local/bin/update-codeql
9+
RUN bash /tmp/root.sh && rm /tmp/root.sh

.devcontainer/swift/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extensions": [
3+
"github.vscode-codeql",
4+
"hbenl.vscode-test-explorer",
5+
"ms-vscode.test-adapter-converter",
6+
"slevesque.vscode-zipexplorer",
7+
"ms-vscode.cpptools"
8+
],
9+
"settings": {
10+
"files.watcherExclude": {
11+
"**/target/**": true
12+
},
13+
"codeQL.runningQueries.memory": 2048
14+
},
15+
"build": {
16+
"dockerfile": "Dockerfile",
17+
},
18+
"runArgs": [
19+
"--cap-add=SYS_PTRACE",
20+
"--security-opt",
21+
"seccomp=unconfined"
22+
],
23+
"remoteUser": "vscode",
24+
"onCreateCommand": ".devcontainer/swift/user.sh"
25+
}

.devcontainer/swift/root.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
set -xe
2+
3+
BAZELISK_VERSION=v1.12.0
4+
BAZELISK_DOWNLOAD_SHA=6b0bcb2ea15bca16fffabe6fda75803440375354c085480fe361d2cbf32501db
5+
6+
apt-get update
7+
export DEBIAN_FRONTEND=noninteractive
8+
apt-get -y install --no-install-recommends \
9+
zlib1g-dev \
10+
uuid-dev \
11+
python3-distutils \
12+
python3-pip \
13+
bash-completion
14+
15+
# Install Bazel
16+
curl -fSsL -o /usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-linux-amd64
17+
echo "${BAZELISK_DOWNLOAD_SHA} */usr/local/bin/bazelisk" | sha256sum --check -
18+
chmod 0755 /usr/local/bin/bazelisk
19+
ln -s bazelisk /usr/local/bin/bazel
20+
21+
# install latest codeql
22+
update-codeql

.devcontainer/swift/update-codeql.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash -e
2+
3+
URL=https://github.com/github/codeql-cli-binaries/releases
4+
LATEST_VERSION=$(curl -L -s -H 'Accept: application/json' $URL/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
5+
CURRENT_VERSION=v$(codeql version 2>/dev/null | sed -ne 's/.*release \([0-9.]*\)\./\1/p')
6+
if [[ $CURRENT_VERSION != $LATEST_VERSION ]]; then
7+
if [[ $UID != 0 ]]; then
8+
echo "update required, please run this script with sudo:"
9+
echo " sudo $0"
10+
exit 1
11+
fi
12+
ZIP=$(mktemp codeql.XXXX.zip)
13+
curl -fSqL -o $ZIP $URL/download/$LATEST_VERSION/codeql-linux64.zip
14+
unzip -q $ZIP -d /opt
15+
rm $ZIP
16+
ln -sf /opt/codeql/codeql /usr/local/bin/codeql
17+
echo installed version $LATEST_VERSION
18+
else
19+
echo current version $CURRENT_VERSION is up-to-date
20+
fi

.devcontainer/swift/user.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set -xe
2+
3+
# add the workspace to the codeql search path
4+
mkdir -p /home/vscode/.config/codeql
5+
echo "--search-path /workspaces/codeql" > /home/vscode/.config/codeql/config
6+
7+
# create a swift extractor pack with the current state
8+
cd /workspaces/codeql
9+
bazel run swift/create-extractor-pack
10+
11+
#install and set up pre-commit
12+
python3 -m pip install pre-commit --no-warn-script-location
13+
$HOME/.local/bin/pre-commit install

.github/workflows/swift-codegen.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,22 @@ jobs:
1515
- uses: actions/checkout@v3
1616
- uses: ./.github/actions/fetch-codeql
1717
- uses: bazelbuild/setup-bazelisk@v2
18+
- uses: actions/setup-python@v3
19+
- uses: pre-commit/[email protected]
20+
name: Check that python code is properly formatted
21+
with:
22+
extra_args: autopep8 --all-files
1823
- name: Run unit tests
1924
run: |
2025
bazel test //swift/codegen/test --test_output=errors
21-
- name: Check that QL generated code was checked in
22-
run: |
23-
bazel run //swift/codegen
24-
git add swift
25-
git diff --exit-code HEAD
26+
- uses: pre-commit/[email protected]
27+
name: Check that QL generated code was checked in
28+
with:
29+
extra_args: swift-codegen --all-files
2630
- name: Generate C++ files
2731
run: |
28-
bazel run //swift/codegen:codegen -- --generate=trap,cpp --cpp-output=$PWD/swift-generated-headers
32+
bazel run //swift/codegen:codegen -- --generate=trap,cpp --cpp-output=$PWD/swift-generated-cpp-files
2933
- uses: actions/upload-artifact@v3
3034
with:
31-
name: swift-generated-headers
32-
path: swift-generated-headers/*.h
35+
name: swift-generated-cpp-files
36+
path: swift-generated-cpp-files/**

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ repos:
1515
- id: clang-format
1616
files: ^swift/.*\.(h|c|cpp)$
1717

18+
- repo: https://github.com/pre-commit/mirrors-autopep8
19+
rev: v1.6.0
20+
hooks:
21+
- id: autopep8
22+
files: ^swift/codegen/.*\.py
23+
1824
- repo: local
1925
hooks:
2026
- id: codeql-format
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: deprecated
3+
---
4+
* The `BarrierGuard` class has been deprecated. Such barriers and sanitizers can now instead be created using the new `BarrierGuard` parameterized module.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: fix
3+
---
4+
* `UserType.getADeclarationEntry()` now yields all forward declarations when the user type is a `class`, `struct`, or `union`.

cpp/ql/lib/semmle/code/cpp/UserType.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class UserType extends Type, Declaration, NameQualifyingElement, AccessHolder, @
4848
}
4949

5050
override TypeDeclarationEntry getADeclarationEntry() {
51-
if type_decls(_, underlyingElement(this), _)
52-
then type_decls(unresolveElement(result), underlyingElement(this), _)
51+
if type_decls(_, unresolveElement(this), _)
52+
then type_decls(underlyingElement(result), unresolveElement(this), _)
5353
else exists(Class t | this.(Class).isConstructedFrom(t) and result = t.getADeclarationEntry())
5454
}
5555

0 commit comments

Comments
 (0)