Skip to content

Commit 44d52d3

Browse files
authored
Merge branch 'main' into main
2 parents 6357614 + f9e7f95 commit 44d52d3

File tree

192 files changed

+5524
-3397
lines changed

Some content is hidden

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

192 files changed

+5524
-3397
lines changed

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
FROM docker.io/library/ubuntu:24.04 as base
1+
FROM docker.io/library/ubuntu:24.04 AS base
22
ENV LLVM_SYSROOT=/opt/llvm
33

4-
FROM base as stage1-toolchain
4+
FROM base AS stage1-toolchain
55
ENV LLVM_VERSION=21.1.1
66

77
RUN apt-get update && \
@@ -37,7 +37,7 @@ RUN cmake -B ./build -G Ninja ./llvm \
3737

3838
RUN ninja -C ./build stage2-clang-bolt stage2-install-distribution && ninja -C ./build install-distribution
3939

40-
FROM base as ci-container
40+
FROM base AS ci-container
4141

4242
COPY --from=stage1-toolchain $LLVM_SYSROOT $LLVM_SYSROOT
4343

@@ -62,6 +62,7 @@ RUN apt-get update && \
6262
# Having a symlink from python to python3 enables code sharing between
6363
# the Linux and Windows pipelines.
6464
python3-pip \
65+
python3-venv \
6566
file \
6667
tzdata \
6768
python-is-python3 && \
@@ -97,7 +98,7 @@ RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
9798
USER gha
9899
WORKDIR /home/gha
99100

100-
FROM ci-container as ci-container-agent
101+
FROM ci-container AS ci-container-agent
101102

102103
ENV GITHUB_RUNNER_VERSION=2.328.0
103104

clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import json
2727
import multiprocessing
2828
import os
29-
import Queue
29+
from queue import Queue
3030
import shutil
3131
import subprocess
3232
import sys
@@ -105,7 +105,7 @@ def main():
105105

106106
try:
107107
# Spin up a bunch of tidy-launching threads.
108-
queue = Queue.Queue(max_task)
108+
queue = Queue(max_task)
109109
for _ in range(max_task):
110110
t = threading.Thread(
111111
target=run_find_all_symbols, args=(args, tmpdir, build_path, queue)

clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ StatementMatcher makeCastSequenceMatcher(llvm::ArrayRef<StringRef> NameList) {
5353
unless(hasImplicitDestinationType(
5454
qualType(matchers::matchesAnyListedTypeName(NameList)))));
5555

56-
auto IsOrHasDescendant = [](auto InnerMatcher) {
56+
auto IsOrHasDescendant = [](const auto &InnerMatcher) {
5757
return anyOf(InnerMatcher, hasDescendant(InnerMatcher));
5858
};
5959

clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,11 @@ ExceptionAnalyzer::throwsException(const Stmt *St,
595595
Results.merge(DestructorExcs);
596596
}
597597
}
598+
} else if (const auto *Lambda = dyn_cast<LambdaExpr>(St)) {
599+
for (const Stmt *Init : Lambda->capture_inits()) {
600+
ExceptionInfo Excs = throwsException(Init, Caught, CallStack);
601+
Results.merge(Excs);
602+
}
598603
} else {
599604
for (const Stmt *Child : St->children()) {
600605
ExceptionInfo Excs = throwsException(Child, Caught, CallStack);

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ Changes in existing checks
244244
correcting a spelling mistake on its option
245245
``NamePrefixSuffixSilenceDissimilarityTreshold``.
246246

247+
- Improved :doc:`bugprone-exception-escape
248+
<clang-tidy/checks/bugprone/exception-escape>` check's handling of lambdas:
249+
exceptions from captures are now diagnosed, exceptions in the bodies of
250+
lambdas that aren't actually invoked are not.
251+
247252
- Improved :doc:`bugprone-infinite-loop
248253
<clang-tidy/checks/bugprone/infinite-loop>` check by adding detection for
249254
variables introduced by structured bindings.
@@ -324,6 +329,11 @@ Changes in existing checks
324329
<clang-tidy/checks/modernize/use-designated-initializers>` check to
325330
suggest using designated initializers for aliased aggregate types.
326331

332+
- Improved :doc:`modernize-use-nullptr
333+
<clang-tidy/checks/modernize/use-nullptr>` check by fixing a crash
334+
on Windows when the check was enabled with a 32-bit :program:`clang-tidy`
335+
binary.
336+
327337
- Improved :doc:`modernize-use-std-format
328338
<clang-tidy/checks/modernize/use-std-format>` check to correctly match
329339
when the format string is converted to a different type by an implicit

clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,3 +894,65 @@ void pointer_exception_can_not_escape_with_void_handler() noexcept {
894894
} catch (void *) {
895895
}
896896
}
897+
898+
void throw_in_uninvoked_lambda() noexcept {
899+
[] { throw 42; };
900+
}
901+
902+
void throw_in_lambda() noexcept {
903+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_in_lambda' which should not throw exceptions
904+
[] { throw 42; }();
905+
// CHECK-MESSAGES: :[[@LINE-1]]:8: note: frame #0: unhandled exception of type 'int' may be thrown in function 'operator()' here
906+
// CHECK-MESSAGES: :[[@LINE-2]]:19: note: frame #1: function 'throw_in_lambda' calls function 'operator()' here
907+
}
908+
909+
struct copy_constructor_throws {
910+
copy_constructor_throws(const copy_constructor_throws&) { throw 42; }
911+
};
912+
913+
void throw_in_lambda_default_by_value_capture(const copy_constructor_throws& a) noexcept {
914+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_in_lambda_default_by_value_capture' which should not throw exceptions
915+
[=] { a; };
916+
// CHECK-MESSAGES: :[[@LINE-6]]:61: note: frame #0: unhandled exception of type 'int' may be thrown in function 'copy_constructor_throws' here
917+
// CHECK-MESSAGES: :[[@LINE-2]]:4: note: frame #1: function 'throw_in_lambda_default_by_value_capture' calls function 'copy_constructor_throws' here
918+
}
919+
920+
void throw_in_lambda_explicit_by_value_capture(const copy_constructor_throws& a) noexcept {
921+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_in_lambda_explicit_by_value_capture' which should not throw exceptions
922+
[a] {};
923+
// CHECK-MESSAGES: :[[@LINE-13]]:61: note: frame #0: unhandled exception of type 'int' may be thrown in function 'copy_constructor_throws' here
924+
// CHECK-MESSAGES: :[[@LINE-2]]:4: note: frame #1: function 'throw_in_lambda_explicit_by_value_capture' calls function 'copy_constructor_throws' here
925+
}
926+
927+
void no_throw_in_lambda_by_reference_capture(const copy_constructor_throws& a) noexcept {
928+
[&] { a; };
929+
[&a] {};
930+
}
931+
932+
void throw_in_lambda_init_capture() noexcept {
933+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_in_lambda_init_capture' which should not throw exceptions
934+
[a = [] { throw 42; return 0; }()] {};
935+
// CHECK-MESSAGES: :[[@LINE-1]]:13: note: frame #0: unhandled exception of type 'int' may be thrown in function 'operator()' here
936+
// CHECK-MESSAGES: :[[@LINE-2]]:34: note: frame #1: function 'throw_in_lambda_init_capture' calls function 'operator()' here
937+
}
938+
939+
void throw_from_nested_lambda() noexcept {
940+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_from_nested_lambda' which should not throw exceptions
941+
[] { [] { throw 42; }(); }();
942+
// CHECK-MESSAGES: :[[@LINE-1]]:13: note: frame #0: unhandled exception of type 'int' may be thrown in function 'operator()' here
943+
// CHECK-MESSAGES: :[[@LINE-2]]:24: note: frame #1: function 'operator()' calls function 'operator()' here
944+
// CHECK-MESSAGES: :[[@LINE-3]]:29: note: frame #2: function 'throw_from_nested_lambda' calls function 'operator()' here
945+
}
946+
947+
const auto throw_in_noexcept_lambda = [] () noexcept { throw 42; };
948+
// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: an exception may be thrown in function 'operator()' which should not throw exceptions
949+
// CHECK-MESSAGES: :[[@LINE-2]]:56: note: frame #0: unhandled exception of type 'int' may be thrown in function 'operator()' here
950+
951+
void thrower() {
952+
throw 42;
953+
}
954+
955+
const auto indirect_throw_in_noexcept_lambda = [] () noexcept { thrower(); };
956+
// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: an exception may be thrown in function 'operator()' which should not throw exceptions
957+
// CHECK-MESSAGES: :[[@LINE-5]]:3: note: frame #0: unhandled exception of type 'int' may be thrown in function 'thrower' here
958+
// CHECK-MESSAGES: :[[@LINE-3]]:65: note: frame #1: function 'operator()' calls function 'thrower' here

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ Improvements to Clang's diagnostics
299299
"format specifies type 'unsigned int' but the argument has type 'int', which differs in signedness [-Wformat-signedness]"
300300
"signedness of format specifier 'u' is incompatible with 'c' [-Wformat-signedness]"
301301
and the API-visible diagnostic id will be appropriate.
302-
302+
- Clang now produces better diagnostics for template template parameter matching
303+
involving 'auto' template parameters.
303304
- Fixed false positives in ``-Waddress-of-packed-member`` diagnostics when
304305
potential misaligned members get processed before they can get discarded.
305306
(#GH144729)
@@ -360,6 +361,7 @@ Bug Fixes in This Version
360361
first parameter. (#GH113323).
361362
- Fixed a crash with incompatible pointer to integer conversions in designated
362363
initializers involving string literals. (#GH154046)
364+
- Fix crash on CTAD for alias template. (#GH131342)
363365
- Clang now emits a frontend error when a function marked with the `flatten` attribute
364366
calls another function that requires target features not enabled in the caller. This
365367
prevents a fatal error in the backend.

clang/include/clang/AST/ExprCXX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4714,7 +4714,7 @@ class SubstNonTypeTemplateParmExpr : public Expr {
47144714
// sugared: it doesn't need to be resugared later.
47154715
bool getFinal() const { return Final; }
47164716

4717-
NamedDecl *getParameter() const;
4717+
NonTypeTemplateParmDecl *getParameter() const;
47184718

47194719
bool isReferenceParameter() const { return AssociatedDeclAndRef.getInt(); }
47204720

clang/include/clang/AST/TypeBase.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3495,7 +3495,9 @@ class AdjustedType : public Type, public llvm::FoldingSetNode {
34953495

34963496
AdjustedType(TypeClass TC, QualType OriginalTy, QualType AdjustedTy,
34973497
QualType CanonicalPtr)
3498-
: Type(TC, CanonicalPtr, OriginalTy->getDependence()),
3498+
: Type(TC, CanonicalPtr,
3499+
AdjustedTy->getDependence() |
3500+
(OriginalTy->getDependence() & ~TypeDependence::Dependent)),
34993501
OriginalTy(OriginalTy), AdjustedTy(AdjustedTy) {}
35003502

35013503
public:

clang/include/clang/Sema/Sema.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11714,6 +11714,23 @@ class Sema final : public SemaBase {
1171411714
const TemplateArgumentListInfo *TemplateArgs,
1171511715
bool IsAddressOfOperand);
1171611716

11717+
UnsignedOrNone getPackIndex(TemplateArgument Pack) const {
11718+
return Pack.pack_size() - 1 - *ArgPackSubstIndex;
11719+
}
11720+
11721+
TemplateArgument
11722+
getPackSubstitutedTemplateArgument(TemplateArgument Arg) const {
11723+
Arg = Arg.pack_elements()[*ArgPackSubstIndex];
11724+
if (Arg.isPackExpansion())
11725+
Arg = Arg.getPackExpansionPattern();
11726+
return Arg;
11727+
}
11728+
11729+
ExprResult BuildSubstNonTypeTemplateParmExpr(
11730+
Decl *AssociatedDecl, const NonTypeTemplateParmDecl *NTTP,
11731+
SourceLocation loc, TemplateArgument Replacement,
11732+
UnsignedOrNone PackIndex, bool Final);
11733+
1171711734
/// Form a template name from a name that is syntactically required to name a
1171811735
/// template, either due to use of the 'template' keyword or because a name in
1171911736
/// this syntactic context is assumed to name a template (C++

0 commit comments

Comments
 (0)