Skip to content

Commit 4a6d402

Browse files
Merge branch 'llvm:main' into copy-inout-dev
2 parents f6f64ca + 2b4b3fd commit 4a6d402

File tree

1,286 files changed

+52188
-27279
lines changed

Some content is hidden

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

1,286 files changed

+52188
-27279
lines changed

.ci/compute_projects_test.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,34 @@ def test_ci(self):
284284
"check-cxx check-cxxabi check-unwind",
285285
)
286286

287+
def test_windows_ci(self):
288+
env_variables = compute_projects.get_env_variables(
289+
[".ci/compute_projects.py"], "Windows"
290+
)
291+
self.assertEqual(
292+
env_variables["projects_to_build"],
293+
"clang;clang-tools-extra;libclc;lld;llvm;mlir;polly",
294+
)
295+
self.assertEqual(
296+
env_variables["project_check_targets"],
297+
"check-clang check-clang-cir check-clang-tools check-lld check-llvm check-mlir check-polly",
298+
)
299+
self.assertEqual(
300+
env_variables["runtimes_to_build"],
301+
"libcxx;libcxxabi;libunwind",
302+
)
303+
self.assertEqual(
304+
env_variables["runtimes_check_targets"],
305+
"",
306+
)
307+
# TODO(boomanaiden154): We should not be emitting these on Windows.
308+
# It does not currently impact anything because we do not build the
309+
# runtimes on Windows though.
310+
self.assertEqual(
311+
env_variables["runtimes_check_targets_needs_reconfig"],
312+
"check-cxx check-cxxabi check-unwind",
313+
)
314+
287315
def test_lldb(self):
288316
env_variables = compute_projects.get_env_variables(
289317
["lldb/CMakeLists.txt"], "Linux"

.github/workflows/libc-fullbuild-tests.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,32 @@ jobs:
2020
include:
2121
- os: ubuntu-24.04
2222
build_type: Debug
23-
ccache-variant: sccache
24-
c_compiler: clang-20
25-
cpp_compiler: clang++-20
23+
c_compiler: clang-22
24+
cpp_compiler: clang++-22
2625
target: x86_64-unknown-linux-llvm
2726
include_scudo: ON
2827
- os: ubuntu-24.04
2928
build_type: Release
30-
ccache-variant: sccache
31-
c_compiler: clang-20
32-
cpp_compiler: clang++-20
29+
c_compiler: clang-22
30+
cpp_compiler: clang++-22
3331
target: x86_64-unknown-linux-llvm
3432
include_scudo: ON
3533
- os: ubuntu-24.04
3634
build_type: MinSizeRel
37-
ccache-variant: sccache
38-
c_compiler: clang-20
39-
cpp_compiler: clang++-20
35+
c_compiler: clang-22
36+
cpp_compiler: clang++-22
4037
target: x86_64-unknown-linux-llvm
4138
include_scudo: ON
42-
# TODO: remove ccache logic when https://github.com/hendrikmuhs/ccache-action/issues/279 is resolved.
4339
- os: ubuntu-24.04-arm
4440
build_type: Debug
45-
ccache-variant: ccache
46-
c_compiler: clang-20
47-
cpp_compiler: clang++-20
41+
c_compiler: clang-22
42+
cpp_compiler: clang++-22
4843
target: aarch64-unknown-linux-llvm
4944
include_scudo: ON
5045
- os: ubuntu-24.04
5146
build_type: Debug
52-
ccache-variant: ccache
53-
c_compiler: clang-20
54-
cpp_compiler: clang++-20
47+
c_compiler: clang-22
48+
cpp_compiler: clang++-22
5549
target: x86_64-unknown-uefi-llvm
5650
include_scudo: OFF
5751
# TODO: add back gcc build when it is fixed
@@ -71,7 +65,7 @@ jobs:
7165
with:
7266
max-size: 1G
7367
key: libc_fullbuild_${{ matrix.c_compiler }}
74-
variant: ${{ matrix.ccache-variant }}
68+
variant: sccache
7569

7670
# Notice:
7771
# - MPFR is required by some of the mathlib tests.
@@ -81,7 +75,7 @@ jobs:
8175
run: |
8276
wget https://apt.llvm.org/llvm.sh
8377
chmod +x llvm.sh
84-
sudo ./llvm.sh 20
78+
sudo ./llvm.sh 22
8579
sudo apt-get update
8680
sudo apt-get install -y libmpfr-dev libgmp-dev libmpc-dev ninja-build linux-libc-dev
8781
sudo ln -sf /usr/include/$(uname -p)-linux-gnu/asm /usr/include/asm
@@ -112,8 +106,8 @@ jobs:
112106
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
113107
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
114108
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
115-
-DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache-variant }} \
116-
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }} \
109+
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
110+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
117111
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }} \
118112
-DLLVM_RUNTIME_TARGETS=${{ matrix.target }} \
119113
-DLLVM_ENABLE_RUNTIMES="$RUNTIMES" \

.github/workflows/libc-overlay-tests.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,22 @@ jobs:
2020
include:
2121
# TODO: add linux gcc when it is fixed
2222
- os: ubuntu-24.04
23-
ccache-variant: sccache
2423
compiler:
2524
c_compiler: clang
2625
cpp_compiler: clang++
27-
# TODO: remove ccache logic when https://github.com/hendrikmuhs/ccache-action/issues/279 is resolved.
2826
- os: ubuntu-24.04-arm
29-
ccache-variant: ccache
3027
compiler:
3128
c_compiler: clang
3229
cpp_compiler: clang++
3330
- os: windows-2022
34-
ccache-variant: sccache
3531
compiler:
3632
c_compiler: clang-cl
3733
cpp_compiler: clang-cl
3834
- os: windows-2025
39-
ccache-variant: sccache
4035
compiler:
4136
c_compiler: clang-cl
4237
cpp_compiler: clang-cl
4338
- os: macos-14
44-
ccache-variant: sccache
4539
compiler:
4640
c_compiler: clang
4741
cpp_compiler: clang++
@@ -61,7 +55,7 @@ jobs:
6155
with:
6256
max-size: 1G
6357
key: libc_overlay_build_${{ matrix.os }}_${{ matrix.compiler.c_compiler }}
64-
variant: ${{ matrix.ccache-variant }}
58+
variant: sccache
6559

6660
# MPFR is required by some of the mathlib tests.
6761
- name: Prepare dependencies (Ubuntu)
@@ -97,8 +91,8 @@ jobs:
9791
-DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp_compiler }}
9892
-DCMAKE_C_COMPILER=${{ matrix.compiler.c_compiler }}
9993
-DCMAKE_BUILD_TYPE=Debug
100-
-DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
101-
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
94+
-DCMAKE_C_COMPILER_LAUNCHER=sccache
95+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
10296
-DCMAKE_POLICY_DEFAULT_CMP0141=NEW
10397
-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded
10498
-DLLVM_ENABLE_RUNTIMES=libc

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ jobs:
260260
- name: Install a current LLVM
261261
if: ${{ matrix.mingw != true }}
262262
run: |
263-
choco install -y llvm --version=19.1.7 --allow-downgrade
263+
choco install -y llvm --version=20.1.8 --allow-downgrade
264264
- name: Install llvm-mingw
265265
if: ${{ matrix.mingw == true }}
266266
run: |
267-
curl -LO https://github.com/mstorsjo/llvm-mingw/releases/download/20250114/llvm-mingw-20250114-ucrt-x86_64.zip
267+
curl -LO https://github.com/mstorsjo/llvm-mingw/releases/download/20250709/llvm-mingw-20250709-ucrt-x86_64.zip
268268
powershell Expand-Archive llvm-mingw*.zip -DestinationPath .
269269
del llvm-mingw*.zip
270270
mv llvm-mingw* c:\llvm-mingw

bolt/test/link_fdata.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import argparse
1111
import os
12+
import platform
1213
import shutil
1314
import subprocess
1415
import sys
@@ -19,7 +20,11 @@
1920
parser.add_argument("objfile", help="Object file to extract symbol values from")
2021
parser.add_argument("output")
2122
parser.add_argument("prefix", nargs="?", default="FDATA", help="Custom FDATA prefix")
22-
parser.add_argument("--nmtool", default="nm", help="Path to nm tool")
23+
parser.add_argument(
24+
"--nmtool",
25+
default="llvm-nm" if platform.system() == "Windows" else "nm",
26+
help="Path to nm tool",
27+
)
2328
parser.add_argument("--no-lbr", action="store_true")
2429
parser.add_argument("--no-redefine", action="store_true")
2530

@@ -86,7 +91,10 @@
8691
exit("ERROR: unexpected input:\n%s" % line)
8792

8893
# Read nm output: <symbol value> <symbol type> <symbol name>
89-
is_llvm_nm = os.path.basename(os.path.realpath(shutil.which(args.nmtool))) == "llvm-nm"
94+
# Ignore .exe on Windows host.
95+
is_llvm_nm = os.path.basename(os.path.realpath(shutil.which(args.nmtool))).startswith(
96+
"llvm-nm"
97+
)
9098
nm_output = subprocess.run(
9199
[
92100
args.nmtool,

clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,23 +349,25 @@ void UnnecessaryCopyInitialization::diagnoseCopyFromMethodReturn(
349349
const CheckContext &Ctx) {
350350
auto Diagnostic =
351351
diag(Ctx.Var.getLocation(),
352-
"the %select{|const qualified }0variable %1 is "
352+
"the %select{|const qualified }0variable %1 of type %2 is "
353353
"copy-constructed "
354354
"from a const reference%select{%select{ but is only used as const "
355-
"reference|}0| but is never used}2; consider "
356-
"%select{making it a const reference|removing the statement}2")
357-
<< Ctx.Var.getType().isConstQualified() << &Ctx.Var << Ctx.IsVarUnused;
355+
"reference|}0| but is never used}3; consider "
356+
"%select{making it a const reference|removing the statement}3")
357+
<< Ctx.Var.getType().isConstQualified() << &Ctx.Var << Ctx.Var.getType()
358+
<< Ctx.IsVarUnused;
358359
maybeIssueFixes(Ctx, Diagnostic);
359360
}
360361

361362
void UnnecessaryCopyInitialization::diagnoseCopyFromLocalVar(
362363
const CheckContext &Ctx, const VarDecl &OldVar) {
363364
auto Diagnostic =
364365
diag(Ctx.Var.getLocation(),
365-
"local copy %1 of the variable %0 is never modified%select{"
366-
"| and never used}2; consider %select{avoiding the copy|removing "
367-
"the statement}2")
368-
<< &OldVar << &Ctx.Var << Ctx.IsVarUnused;
366+
"local copy %0 of the variable %1 of type %2 is never "
367+
"modified%select{"
368+
"| and never used}3; consider %select{avoiding the copy|removing "
369+
"the statement}3")
370+
<< &Ctx.Var << &OldVar << Ctx.Var.getType() << Ctx.IsVarUnused;
369371
maybeIssueFixes(Ctx, Diagnostic);
370372
}
371373

clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,12 @@ void UnnecessaryValueParamCheck::handleConstRefFix(const FunctionDecl &Function,
143143

144144
auto Diag =
145145
diag(Param.getLocation(),
146-
"the %select{|const qualified }0parameter %1 is copied for each "
146+
"the %select{|const qualified }0parameter %1 of type %2 is copied "
147+
"for each "
147148
"invocation%select{ but only used as a const reference|}0; consider "
148149
"making it a %select{const |}0reference")
149-
<< IsConstQualified << paramNameOrIndex(Param.getName(), Index);
150+
<< IsConstQualified << paramNameOrIndex(Param.getName(), Index)
151+
<< Param.getType();
150152
// Do not propose fixes when:
151153
// 1. the ParmVarDecl is in a macro, since we cannot place them correctly
152154
// 2. the function is virtual as it might break overrides
@@ -173,10 +175,11 @@ void UnnecessaryValueParamCheck::handleConstRefFix(const FunctionDecl &Function,
173175
void UnnecessaryValueParamCheck::handleMoveFix(const ParmVarDecl &Param,
174176
const DeclRefExpr &CopyArgument,
175177
ASTContext &Context) {
176-
auto Diag = diag(CopyArgument.getBeginLoc(),
177-
"parameter %0 is passed by value and only copied once; "
178-
"consider moving it to avoid unnecessary copies")
179-
<< &Param;
178+
auto Diag =
179+
diag(CopyArgument.getBeginLoc(),
180+
"parameter %0 of type %1 is passed by value and only copied once; "
181+
"consider moving it to avoid unnecessary copies")
182+
<< &Param << Param.getType();
180183
// Do not propose fixes in macros since we cannot place them correctly.
181184
if (CopyArgument.getBeginLoc().isMacroID())
182185
return;

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -859,17 +859,47 @@ std::vector<DocumentLink> getDocumentLinks(ParsedAST &AST) {
859859
for (auto &Inc : AST.getIncludeStructure().MainFileIncludes) {
860860
if (Inc.Resolved.empty())
861861
continue;
862+
863+
// Get the location of the # symbole of the "#include ..." statement
862864
auto HashLoc = SM.getComposedLoc(SM.getMainFileID(), Inc.HashOffset);
865+
866+
// get the # Token itself, std::next to get the "include" token and the
867+
// first token after (aka "File Token")
863868
const auto *HashTok = AST.getTokens().spelledTokenContaining(HashLoc);
864869
assert(HashTok && "got inclusion at wrong offset");
865870
const auto *IncludeTok = std::next(HashTok);
866871
const auto *FileTok = std::next(IncludeTok);
867-
// FileTok->range is not sufficient here, as raw lexing wouldn't yield
868-
// correct tokens for angled filenames. Hence we explicitly use
869-
// Inc.Written's length.
870-
auto FileRange =
871-
syntax::FileRange(SM, FileTok->location(), Inc.Written.length())
872-
.toCharRange(SM);
872+
873+
// The File Token can either be of kind :
874+
// "less" if using the "#include <h-char-sequence> new-line" syntax
875+
// "string_literal" if using the "#include "q-char-sequence" new-line"
876+
// syntax something else (most likely "identifier") if using the "#include
877+
// pp-tokens new-line" syntax (#include with macro argument)
878+
879+
CharSourceRange FileRange;
880+
881+
if (FileTok->kind() == tok::TokenKind::less) {
882+
// FileTok->range would only include the '<' char. Hence we explicitly use
883+
// Inc.Written's length.
884+
FileRange =
885+
syntax::FileRange(SM, FileTok->location(), Inc.Written.length())
886+
.toCharRange(SM);
887+
} else if (FileTok->kind() == tok::TokenKind::string_literal) {
888+
// FileTok->range includes the quotes for string literals so just return
889+
// it.
890+
FileRange = FileTok->range(SM).toCharRange(SM);
891+
} else {
892+
// FileTok is the first Token of a macro spelling
893+
894+
// Report the range of the first token (as it should be the macro
895+
// identifier)
896+
// We could use the AST to find the last spelled token of the macro and
897+
// report a range spanning the full macro expression, but it would require
898+
// using token-buffers that are deemed too unstable and crash-prone
899+
// due to optimizations in cland
900+
901+
FileRange = FileTok->range(SM).toCharRange(SM);
902+
}
873903

874904
Result.push_back(
875905
DocumentLink({halfOpenToRange(SM, FileRange),

clang-tools-extra/clangd/unittests/XRefsTests.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,14 +2784,24 @@ TEST(GetNonLocalDeclRefs, All) {
27842784

27852785
TEST(DocumentLinks, All) {
27862786
Annotations MainCpp(R"cpp(
2787+
#define HEADER_AA "faa.h"
2788+
#define HEADER_BB "fbb.h"
2789+
#define GET_HEADER(X) HEADER_ ## X
2790+
27872791
#/*comments*/include /*comments*/ $foo[["foo.h"]] //more comments
27882792
int end_of_preamble = 0;
27892793
#include $bar[[<bar.h>]]
2794+
#include $AA[[GET_HEADER]](AA) // Some comment !
2795+
# /* What about */ \
2796+
include /* multiple line */ \
2797+
$BB[[GET_HEADER]]( /* statements ? */ \
2798+
BB /* :) */ )
27902799
)cpp");
27912800

27922801
TestTU TU;
27932802
TU.Code = std::string(MainCpp.code());
2794-
TU.AdditionalFiles = {{"foo.h", ""}, {"bar.h", ""}};
2803+
TU.AdditionalFiles = {
2804+
{"faa.h", ""}, {"fbb.h", ""}, {"foo.h", ""}, {"bar.h", ""}};
27952805
TU.ExtraArgs = {"-isystem."};
27962806
auto AST = TU.build();
27972807

@@ -2801,7 +2811,11 @@ TEST(DocumentLinks, All) {
28012811
DocumentLink({MainCpp.range("foo"),
28022812
URIForFile::canonicalize(testPath("foo.h"), "")}),
28032813
DocumentLink({MainCpp.range("bar"),
2804-
URIForFile::canonicalize(testPath("bar.h"), "")})));
2814+
URIForFile::canonicalize(testPath("bar.h"), "")}),
2815+
DocumentLink({MainCpp.range("AA"),
2816+
URIForFile::canonicalize(testPath("faa.h"), "")}),
2817+
DocumentLink({MainCpp.range("BB"),
2818+
URIForFile::canonicalize(testPath("fbb.h"), "")})));
28052819
}
28062820

28072821
} // namespace

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ Changes in existing checks
170170
when the format string is converted to a different type by an implicit
171171
constructor call.
172172

173+
- Improved :doc:`performance-unnecessary-copy-initialization
174+
<clang-tidy/checks/performance/unnecessary-copy-initialization>` by printing
175+
the type of the diagnosed variable.
176+
177+
- Improved :doc:`performance-unnecessary-value-param
178+
<clang-tidy/checks/performance/unnecessary-value-param>` by printing
179+
the type of the diagnosed variable.
180+
173181
- Improved :doc:`portability-template-virtual-member-function
174182
<clang-tidy/checks/portability/template-virtual-member-function>` check to
175183
avoid false positives on pure virtual member functions.

0 commit comments

Comments
 (0)