Skip to content

Commit 8cfb902

Browse files
committed
Merge 8a06436 into cheriot-upstream
2 parents 74782d4 + 8a06436 commit 8cfb902

File tree

601 files changed

+17649
-5468
lines changed

Some content is hidden

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

601 files changed

+17649
-5468
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: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,30 @@ jobs:
2020
include:
2121
- os: ubuntu-24.04
2222
build_type: Debug
23-
ccache-variant: sccache
2423
c_compiler: clang-22
2524
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
3129
c_compiler: clang-22
3230
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
3835
c_compiler: clang-22
3936
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
4641
c_compiler: clang-22
4742
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
5347
c_compiler: clang-22
5448
cpp_compiler: clang++-22
5549
target: x86_64-unknown-uefi-llvm
@@ -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.
@@ -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

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/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.

clang-tools-extra/include-cleaner/lib/Record.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "clang/Basic/FileEntry.h"
1515
#include "clang/Basic/FileManager.h"
1616
#include "clang/Basic/LLVM.h"
17+
#include "clang/Basic/LangOptions.h"
1718
#include "clang/Basic/SourceLocation.h"
1819
#include "clang/Basic/SourceManager.h"
1920
#include "clang/Basic/Specifiers.h"
@@ -179,8 +180,10 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, public CommentHandler {
179180
RecordPragma(const CompilerInstance &CI, PragmaIncludes *Out)
180181
: RecordPragma(CI.getPreprocessor(), Out) {}
181182
RecordPragma(const Preprocessor &P, PragmaIncludes *Out)
182-
: SM(P.getSourceManager()), HeaderInfo(P.getHeaderSearchInfo()), Out(Out),
183-
Arena(std::make_shared<llvm::BumpPtrAllocator>()),
183+
: SM(P.getSourceManager()), HeaderInfo(P.getHeaderSearchInfo()),
184+
L(P.getLangOpts().CPlusPlus ? tooling::stdlib::Lang::CXX
185+
: tooling::stdlib::Lang::C),
186+
Out(Out), Arena(std::make_shared<llvm::BumpPtrAllocator>()),
184187
UniqueStrings(*Arena),
185188
MainFileStem(llvm::sys::path::stem(
186189
SM.getNonBuiltinFilenameForID(SM.getMainFileID()).value_or(""))) {}
@@ -224,7 +227,7 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, public CommentHandler {
224227
std::optional<Header> IncludedHeader;
225228
if (IsAngled)
226229
if (auto StandardHeader =
227-
tooling::stdlib::Header::named("<" + FileName.str() + ">")) {
230+
tooling::stdlib::Header::named("<" + FileName.str() + ">", L)) {
228231
IncludedHeader = *StandardHeader;
229232
}
230233
if (!IncludedHeader && File)
@@ -363,6 +366,7 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, public CommentHandler {
363366
bool InMainFile = false;
364367
const SourceManager &SM;
365368
const HeaderSearch &HeaderInfo;
369+
const tooling::stdlib::Lang L;
366370
PragmaIncludes *Out;
367371
std::shared_ptr<llvm::BumpPtrAllocator> Arena;
368372
/// Intern table for strings. Contents are on the arena.

clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "clang/Frontend/FrontendActions.h"
1919
#include "clang/Frontend/FrontendOptions.h"
2020
#include "clang/Serialization/PCHContainerOperations.h"
21+
#include "clang/Testing/CommandLineArgs.h"
2122
#include "clang/Testing/TestAST.h"
2223
#include "clang/Tooling/Inclusions/StandardLibrary.h"
2324
#include "llvm/ADT/ArrayRef.h"
@@ -514,6 +515,26 @@ TEST_F(PragmaIncludeTest, IWYUExportForStandardHeaders) {
514515
testing::UnorderedElementsAre(FileNamed("export.h")));
515516
}
516517

518+
TEST_F(PragmaIncludeTest, IWYUExportForStandardHeadersRespectsLang) {
519+
Inputs.Code = R"cpp(
520+
#include "export.h"
521+
)cpp";
522+
Inputs.Language = TestLanguage::Lang_C99;
523+
Inputs.ExtraFiles["export.h"] = R"cpp(
524+
#include <stdlib.h> // IWYU pragma: export
525+
)cpp";
526+
Inputs.ExtraFiles["stdlib.h"] = "";
527+
Inputs.ExtraArgs = {"-isystem."};
528+
TestAST Processed = build();
529+
auto &FM = Processed.fileManager();
530+
EXPECT_THAT(PI.getExporters(*tooling::stdlib::Header::named(
531+
"<stdlib.h>", tooling::stdlib::Lang::C),
532+
FM),
533+
testing::UnorderedElementsAre(FileNamed("export.h")));
534+
EXPECT_THAT(PI.getExporters(llvm::cantFail(FM.getFileRef("stdlib.h")), FM),
535+
testing::UnorderedElementsAre(FileNamed("export.h")));
536+
}
537+
517538
TEST_F(PragmaIncludeTest, IWYUExportBlock) {
518539
Inputs.Code = R"cpp(// Line 1
519540
#include "normal.h"

clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization-allowed-types.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void negative_smart_ref() {
8888

8989
void positiveOtherType() {
9090
const auto O = getOtherType();
91-
// CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'O' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
91+
// CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'O' of type 'const OtherType' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
9292
// CHECK-FIXES: const auto& O = getOtherType();
9393
O.constMethod();
9494
}

0 commit comments

Comments
 (0)