Skip to content

Commit 89bab96

Browse files
committed
Merge LLVM 21.x changes
2 parents 16b5ac8 + 4582a80 commit 89bab96

File tree

38 files changed

+483
-131
lines changed

38 files changed

+483
-131
lines changed

.github/workflows/libclang-abi-tests.yml

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
LLVM_VERSION_PATCH: ${{ steps.version.outputs.patch }}
3939
steps:
4040
- name: Checkout source
41-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
41+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4242
with:
4343
fetch-depth: 250
4444

@@ -84,6 +84,8 @@ jobs:
8484
if: github.repository_owner == 'llvm'
8585
needs: abi-dump-setup
8686
runs-on: ubuntu-24.04
87+
container:
88+
image: "ghcr.io/llvm/ci-ubuntu-24.04-abi-tests@sha256:f80125c0f767e29b8616210c0fd5cea2cd1f4fb6f2ca86d89f6016b6329b8d7f" #ghcr.io/llvm/ci-ubuntu-24.04-abi-tests:9524b37c503f
8789
strategy:
8890
matrix:
8991
name:
@@ -100,23 +102,12 @@ jobs:
100102
repo: ${{ github.repository }}
101103
steps:
102104
- name: Install Ninja
103-
uses: llvm/actions/install-ninja@main
104-
- name: Install abi-compliance-checker
105-
run: |
106-
sudo apt-get update
107-
sudo apt-get install -y abi-dumper autoconf pkg-config
108-
- name: Install universal-ctags
109-
run: |
110-
git clone https://github.com/universal-ctags/ctags.git
111-
cd ctags
112-
./autogen.sh
113-
./configure
114-
sudo make install
105+
uses: llvm/actions/install-ninja@42d80571b13f4599bbefbc7189728b64723c7f78 # main
115106
- name: Download source code
116-
uses: llvm/actions/get-llvm-project-src@main
107+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
117108
with:
118109
ref: ${{ matrix.ref }}
119-
repo: ${{ matrix.repo }}
110+
repository: ${{ matrix.repo }}
120111
- name: Configure
121112
run: |
122113
mkdir install
@@ -131,41 +122,39 @@ jobs:
131122
sed -i 's/LLVM_[0-9]\+/LLVM_NOVERSION/' $lib-${{ matrix.ref }}.abi
132123
done
133124
- name: Upload ABI file
134-
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # 4.6.0
125+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # 5.0.0
135126
with:
136127
name: ${{ matrix.name }}
137128
path: '*${{ matrix.ref }}.abi'
138129

139130
abi-compare:
140131
if: github.repository_owner == 'llvm'
141132
runs-on: ubuntu-24.04
133+
container:
134+
image: "ghcr.io/llvm/ci-ubuntu-24.04-abi-tests@sha256:f80125c0f767e29b8616210c0fd5cea2cd1f4fb6f2ca86d89f6016b6329b8d7f" #ghcr.io/llvm/ci-ubuntu-24.04-abi-tests:9524b37c503f
142135
needs:
143136
- abi-dump-setup
144137
- abi-dump
145138
steps:
146139
- name: Download baseline
147-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # 4.1.8
140+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
148141
with:
149142
name: build-baseline
150143
path: build-baseline
151144
- name: Download latest
152-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # 4.1.8
145+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
153146
with:
154147
name: build-latest
155148
path: build-latest
156149

157-
- name: Install abi-compliance-checker
158-
run: |
159-
sudo apt-get update
160-
sudo apt-get install -y abi-compliance-checker
161150
- name: Compare ABI
162151
run: |
163152
for lib in ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}; do
164153
abi-compliance-checker -lib $lib -old build-baseline/$lib*.abi -new build-latest/$lib*.abi
165154
done
166155
- name: Upload ABI Comparison
167156
if: always()
168-
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # 4.6.0
157+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # 5.0.0
169158
with:
170159
name: compat-report-${{ github.sha }}
171160
path: compat_reports/
Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: LLVM Tests
1+
name: LLVM ABI Tests
22

33
permissions:
44
contents: read
@@ -10,13 +10,13 @@ on:
1010
- 'release/**'
1111
paths:
1212
- 'llvm/**'
13-
- '.github/workflows/llvm-tests.yml'
13+
- '.github/workflows/llvm-abi-tests.yml'
1414
pull_request:
1515
branches:
1616
- 'release/**'
1717
paths:
1818
- 'llvm/**'
19-
- '.github/workflows/llvm-tests.yml'
19+
- '.github/workflows/llvm-abi-tests.yml'
2020

2121
concurrency:
2222
# Skip intermediate builds: always.
@@ -38,7 +38,7 @@ jobs:
3838
LLVM_VERSION_PATCH: ${{ steps.version.outputs.patch }}
3939
steps:
4040
- name: Checkout source
41-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
41+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4242
with:
4343
fetch-depth: 250
4444

@@ -72,6 +72,8 @@ jobs:
7272
if: github.repository_owner == 'llvm'
7373
needs: abi-dump-setup
7474
runs-on: ubuntu-24.04
75+
container:
76+
image: "ghcr.io/llvm/ci-ubuntu-24.04-abi-tests@sha256:01e66b0847c1e9c88f0bd0492ed7c3374550a0730b48040f63888393f1ff6c13" #ghcr.io/llvm/ci-ubuntu-24.04-abi-tests:bb0bd382ab2b"
7577
strategy:
7678
matrix:
7779
name:
@@ -87,24 +89,11 @@ jobs:
8789
ref: ${{ github.sha }}
8890
repo: ${{ github.repository }}
8991
steps:
90-
- name: Install Ninja
91-
uses: llvm/actions/install-ninja@main
92-
- name: Install abi-compliance-checker
93-
run: |
94-
sudo apt-get update
95-
sudo apt-get -y install abi-dumper autoconf pkg-config
96-
- name: Install universal-ctags
97-
run: |
98-
git clone https://github.com/universal-ctags/ctags.git
99-
cd ctags
100-
./autogen.sh
101-
./configure
102-
sudo make install
10392
- name: Download source code
104-
uses: llvm/actions/get-llvm-project-src@main
93+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
10594
with:
10695
ref: ${{ matrix.ref }}
107-
repo: ${{ matrix.repo }}
96+
repository: ${{ matrix.repo }}
10897
- name: Configure
10998
run: |
11099
mkdir install
@@ -128,45 +117,43 @@ jobs:
128117
# Remove symbol versioning from dumps, so we can compare across major versions.
129118
sed -i 's/LLVM_${{ matrix.llvm_version_major }}/LLVM_NOVERSION/' ${{ matrix.ref }}.abi
130119
- name: Upload ABI file
131-
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # 4.6.0
120+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # 5.0.0
132121
with:
133122
name: ${{ matrix.name }}
134123
path: ${{ matrix.ref }}.abi
135124

136125
- name: Upload symbol list file
137126
if: matrix.name == 'build-baseline'
138-
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # 4.6.0
127+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # 5.0.0
139128
with:
140129
name: symbol-list
141130
path: llvm.symbols
142131

143132
abi-compare:
144133
if: github.repository_owner == 'llvm'
145134
runs-on: ubuntu-24.04
135+
container:
136+
image: "ghcr.io/llvm/ci-ubuntu-24.04-abi-tests@sha256:01e66b0847c1e9c88f0bd0492ed7c3374550a0730b48040f63888393f1ff6c13" #ghcr.io/llvm/ci-ubuntu-24.04-abi-tests:bb0bd382ab2b
146137
needs:
147138
- abi-dump-setup
148139
- abi-dump
149140
steps:
150141
- name: Download baseline
151-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # 4.1.8
142+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
152143
with:
153144
name: build-baseline
154145
path: build-baseline
155146
- name: Download latest
156-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # 4.1.8
147+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
157148
with:
158149
name: build-latest
159150
path: build-latest
160151
- name: Download symbol list
161-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # 4.1.8
152+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
162153
with:
163154
name: symbol-list
164155
path: symbol-list
165156

166-
- name: Install abi-compliance-checker
167-
run: |
168-
sudo apt-get update
169-
sudo apt-get -y install abi-compliance-checker
170157
- name: Compare ABI
171158
run: |
172159
if [ -s symbol-list/llvm.symbols ]; then
@@ -179,7 +166,7 @@ jobs:
179166
abi-compliance-checker $EXTRA_ARGS -l libLLVM.so -old build-baseline/*.abi -new build-latest/*.abi || test "${{ needs.abi-dump-setup.outputs.ABI_HEADERS }}" = "llvm-c"
180167
- name: Upload ABI Comparison
181168
if: always()
182-
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # 4.6.0
169+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # 5.0.0
183170
with:
184171
name: compat-report-${{ github.sha }}
185172
path: compat_reports/

clang-tools-extra/clangd/GlobalCompilationDatabase.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,10 @@ bool OverlayCDB::setCompileCommand(PathRef File,
833833
std::unique_ptr<ProjectModules>
834834
OverlayCDB::getProjectModules(PathRef File) const {
835835
auto MDB = DelegatingCDB::getProjectModules(File);
836+
if (!MDB) {
837+
log("Failed to get compilation Database for {0}", File);
838+
return {};
839+
}
836840
MDB->setCommandMangler([&Mangler = Mangler](tooling::CompileCommand &Command,
837841
PathRef CommandPath) {
838842
Mangler(Command, CommandPath);
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# A smoke test to check that clangd works without compilation database
2+
#
3+
# Windows have different escaping modes.
4+
# FIXME: We should add one for windows.
5+
# UNSUPPORTED: system-windows
6+
#
7+
# RUN: rm -fr %t
8+
# RUN: mkdir -p %t
9+
# RUN: split-file %s %t
10+
#
11+
# RUN: sed -e "s|DIR|%/t|g" %t/definition.jsonrpc.tmpl > %t/definition.jsonrpc
12+
#
13+
# RUN: clangd -experimental-modules-support -lit-test < %t/definition.jsonrpc \
14+
# RUN: | FileCheck -strict-whitespace %t/definition.jsonrpc
15+
16+
#--- A.h
17+
void printA();
18+
19+
#--- Use.cpp
20+
#include "A.h"
21+
void foo() {
22+
print
23+
}
24+
25+
#--- definition.jsonrpc.tmpl
26+
{
27+
"jsonrpc": "2.0",
28+
"id": 0,
29+
"method": "initialize",
30+
"params": {
31+
"processId": 123,
32+
"rootPath": "clangd",
33+
"capabilities": {
34+
"textDocument": {
35+
"completion": {
36+
"completionItem": {
37+
"snippetSupport": true
38+
}
39+
}
40+
}
41+
},
42+
"trace": "off"
43+
}
44+
}
45+
---
46+
{
47+
"jsonrpc": "2.0",
48+
"method": "textDocument/didOpen",
49+
"params": {
50+
"textDocument": {
51+
"uri": "file://DIR/Use.cpp",
52+
"languageId": "cpp",
53+
"version": 1,
54+
"text": "#include \"A.h\"\nvoid foo() {\n print\n}\n"
55+
}
56+
}
57+
}
58+
59+
# CHECK: "message"{{.*}}printA{{.*}}(fix available)
60+
61+
---
62+
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file://DIR/Use.cpp"},"context":{"triggerKind":1},"position":{"line":2,"character":6}}}
63+
---
64+
{"jsonrpc":"2.0","id":2,"method":"shutdown"}
65+
---
66+
{"jsonrpc":"2.0","method":"exit"}

clang/cmake/caches/Release.cmake

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
4444
set(LLVM_RELEASE_ENABLE_PGO ON CACHE BOOL "")
4545
set(LLVM_RELEASE_ENABLE_RUNTIMES ${DEFAULT_RUNTIMES} CACHE STRING "")
4646
set(LLVM_RELEASE_ENABLE_PROJECTS ${DEFAULT_PROJECTS} CACHE STRING "")
47+
48+
# This option enables linking stage2 clang statically with the runtimes
49+
# (libc++ and compiler-rt) from stage1. In theory this will give the
50+
# binaries better performance and make them more portable. However,
51+
# this configuration is not well tested and causes build failures with
52+
# the flang-rt tests cases, since the -stclib=libc++ flag does not
53+
# get propagated to the runtimes build. There is also a separate
54+
# issue on Darwin where clang will use the local libc++ headers, but
55+
# link with system libc++ which can cause some incompatibilities.
56+
# See https://github.com/llvm/llvm-project/issues/77653
57+
# Because of these problems, this option will default to OFF.
58+
set(LLVM_RELEASE_ENABLE_LINK_LOCAL_RUNTIMES OFF CACHE BOOL "")
59+
4760
# Note we don't need to add install here, since it is one of the pre-defined
4861
# steps.
4962
set(LLVM_RELEASE_FINAL_STAGE_TARGETS "clang;package;check-all;check-llvm;check-clang" CACHE STRING "")
@@ -55,8 +68,12 @@ set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
5568

5669
set(STAGE1_PROJECTS "clang")
5770

71+
# Need to build compiler-rt in order to use PGO for later stages.
72+
set(STAGE1_RUNTIMES "compiler-rt")
5873
# Build all runtimes so we can statically link them into the stage2 compiler.
59-
set(STAGE1_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind")
74+
if(LLVM_RELEASE_ENABLE_LINK_LOCAL_RUNTIMES)
75+
list(APPEND STAGE1_RUNTIMES "libcxx;libcxxabi;libunwind")
76+
endif()
6077

6178
if (LLVM_RELEASE_ENABLE_PGO)
6279
list(APPEND STAGE1_PROJECTS "lld")
@@ -118,21 +135,25 @@ set_instrument_and_final_stage_var(LLVM_ENABLE_LTO "${LLVM_RELEASE_ENABLE_LTO}"
118135
if (LLVM_RELEASE_ENABLE_LTO)
119136
set_instrument_and_final_stage_var(LLVM_ENABLE_LLD "ON" BOOL)
120137
endif()
121-
set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL)
122-
set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL)
123-
set(RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind")
124-
if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
125-
set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc")
138+
if(LLVM_RELEASE_ENABLE_LINK_LOCAL_RUNTIMES)
139+
set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL)
140+
set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL)
141+
set(RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind")
142+
if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
143+
set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc")
144+
endif()
126145
endif()
127146

128147
# Set flags for bolt
129148
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
130149
set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -Wl,--emit-relocs,-znow")
131150
endif()
132151

133-
set_instrument_and_final_stage_var(CMAKE_EXE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
134-
set_instrument_and_final_stage_var(CMAKE_SHARED_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
135-
set_instrument_and_final_stage_var(CMAKE_MODULE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
152+
if (RELEASE_LINKER_FLAGS)
153+
set_instrument_and_final_stage_var(CMAKE_EXE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
154+
set_instrument_and_final_stage_var(CMAKE_SHARED_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
155+
set_instrument_and_final_stage_var(CMAKE_MODULE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
156+
endif()
136157

137158
# Final Stage Config (stage2)
138159
set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING)

clang/lib/Format/QualifierAlignmentFixer.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,11 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeRight(
182182
// We only need to think about streams that begin with a qualifier.
183183
if (Tok->isNot(QualifierType))
184184
return Tok;
185+
186+
const auto *Next = Tok->getNextNonComment();
187+
185188
// Don't concern yourself if nothing follows the qualifier.
186-
if (!Tok->Next)
189+
if (!Next)
187190
return Tok;
188191

189192
// Skip qualifiers to the left to find what preceeds the qualifiers.
@@ -247,9 +250,15 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeRight(
247250
}();
248251

249252
// Find the last qualifier to the right.
250-
const FormatToken *LastQual = Tok;
251-
while (isQualifier(LastQual->getNextNonComment()))
252-
LastQual = LastQual->getNextNonComment();
253+
const auto *LastQual = Tok;
254+
for (; isQualifier(Next); Next = Next->getNextNonComment())
255+
LastQual = Next;
256+
257+
if (!LastQual || !Next ||
258+
(LastQual->isOneOf(tok::kw_const, tok::kw_volatile) &&
259+
Next->isOneOf(Keywords.kw_override, Keywords.kw_final))) {
260+
return Tok;
261+
}
253262

254263
// If this qualifier is to the right of a type or pointer do a partial sort
255264
// and return.

0 commit comments

Comments
 (0)