Skip to content

Commit 81082ed

Browse files
author
z1.cciauto
committed
merge main into amd-staging
2 parents 56099e0 + aa27d4e commit 81082ed

File tree

218 files changed

+6405
-2820
lines changed

Some content is hidden

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

218 files changed

+6405
-2820
lines changed

.ci/monolithic-windows.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
7474
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
7575
-D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \
7676
-D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \
77-
-D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO" \
78-
-D LLVM_PARALLEL_COMPILE_JOBS=${MAX_PARALLEL_COMPILE_JOBS} \
79-
-D LLVM_PARALLEL_LINK_JOBS=${MAX_PARALLEL_LINK_JOBS}
77+
-D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO"
8078

8179
echo "::endgroup::"
8280
echo "::group::ninja"

.github/workflows/premerge.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ jobs:
110110
if: ${{ steps.vars.outputs.windows-projects != '' }}
111111
shell: cmd
112112
run: |
113-
set MAX_PARALLEL_COMPILE_JOBS=64
114-
set MAX_PARALLEL_LINK_JOBS=64
115113
call C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64
116114
bash .ci/monolithic-windows.sh "${{ steps.vars.outputs.windows-projects }}" "${{ steps.vars.outputs.windows-check-targets }}"
117115
- name: Upload Artifacts

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

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,21 @@ using namespace llvm;
2020

2121
namespace clang::tidy::modernize {
2222

23+
static bool isFirstFriendOfSecond(const CXXRecordDecl *Friend,
24+
const CXXRecordDecl *Class) {
25+
return llvm::any_of(
26+
Class->friends(), [Friend](FriendDecl *FriendDecl) -> bool {
27+
if (TypeSourceInfo *FriendTypeSource = FriendDecl->getFriendType()) {
28+
const QualType FriendType = FriendTypeSource->getType();
29+
return FriendType->getAsCXXRecordDecl() == Friend;
30+
}
31+
return false;
32+
});
33+
}
34+
2335
namespace {
24-
/// Matches move-constructible classes.
36+
/// Matches move-constructible classes whose constructor can be called inside
37+
/// a CXXRecordDecl with a bound ID.
2538
///
2639
/// Given
2740
/// \code
@@ -32,15 +45,33 @@ namespace {
3245
/// Bar(Bar &&) = deleted;
3346
/// int a;
3447
/// };
48+
///
49+
/// class Buz {
50+
/// Buz(Buz &&);
51+
/// int a;
52+
/// friend class Outer;
53+
/// };
54+
///
55+
/// class Outer {
56+
/// };
3557
/// \endcode
36-
/// recordDecl(isMoveConstructible())
37-
/// matches "Foo".
38-
AST_MATCHER(CXXRecordDecl, isMoveConstructible) {
39-
for (const CXXConstructorDecl *Ctor : Node.ctors()) {
40-
if (Ctor->isMoveConstructor() && !Ctor->isDeleted())
41-
return true;
42-
}
43-
return false;
58+
/// recordDecl(isMoveConstructibleInBoundCXXRecordDecl("Outer"))
59+
/// matches "Foo", "Buz".
60+
AST_MATCHER_P(CXXRecordDecl, isMoveConstructibleInBoundCXXRecordDecl, StringRef,
61+
RecordDeclID) {
62+
return Builder->removeBindings(
63+
[this,
64+
&Node](const ast_matchers::internal::BoundNodesMap &Nodes) -> bool {
65+
const auto *BoundClass =
66+
Nodes.getNode(this->RecordDeclID).get<CXXRecordDecl>();
67+
for (const CXXConstructorDecl *Ctor : Node.ctors()) {
68+
if (Ctor->isMoveConstructor() && !Ctor->isDeleted() &&
69+
(Ctor->getAccess() == AS_public ||
70+
(BoundClass && isFirstFriendOfSecond(BoundClass, &Node))))
71+
return false;
72+
}
73+
return true;
74+
});
4475
}
4576
} // namespace
4677

@@ -202,6 +233,7 @@ void PassByValueCheck::registerMatchers(MatchFinder *Finder) {
202233
traverse(
203234
TK_AsIs,
204235
cxxConstructorDecl(
236+
ofClass(cxxRecordDecl().bind("outer")),
205237
forEachConstructorInitializer(
206238
cxxCtorInitializer(
207239
unless(isBaseInitializer()),
@@ -225,8 +257,9 @@ void PassByValueCheck::registerMatchers(MatchFinder *Finder) {
225257
.bind("Param"))))),
226258
hasDeclaration(cxxConstructorDecl(
227259
isCopyConstructor(), unless(isDeleted()),
228-
hasDeclContext(
229-
cxxRecordDecl(isMoveConstructible())))))))
260+
hasDeclContext(cxxRecordDecl(
261+
isMoveConstructibleInBoundCXXRecordDecl(
262+
"outer"))))))))
230263
.bind("Initializer")))
231264
.bind("Ctor")),
232265
this);

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ Changes in existing checks
281281
excluding variables with ``thread_local`` storage class specifier from being
282282
matched.
283283

284+
- Improved :doc:`modernize-pass-by-value
285+
<clang-tidy/checks/modernize/pass-by-value>` check by fixing false positives
286+
when class passed by const-reference had a private move constructor.
287+
284288
- Improved :doc:`modernize-type-traits
285289
<clang-tidy/checks/modernize/type-traits>` check by detecting more type traits.
286290

clang-tools-extra/test/clang-tidy/checkers/modernize/pass-by-value.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,62 @@ struct W3 {
252252
W3(W1 &&, Movable &&M);
253253
Movable M;
254254
};
255+
256+
struct ProtectedMovable {
257+
ProtectedMovable() = default;
258+
ProtectedMovable(const ProtectedMovable &) {}
259+
protected:
260+
ProtectedMovable(ProtectedMovable &&) {}
261+
};
262+
263+
struct PrivateMovable {
264+
PrivateMovable() = default;
265+
PrivateMovable(const PrivateMovable &) {}
266+
private:
267+
PrivateMovable(PrivateMovable &&) {}
268+
269+
friend struct X5;
270+
};
271+
272+
struct InheritedProtectedMovable : ProtectedMovable {
273+
InheritedProtectedMovable() = default;
274+
InheritedProtectedMovable(const InheritedProtectedMovable &) {}
275+
InheritedProtectedMovable(InheritedProtectedMovable &&) {}
276+
};
277+
278+
struct InheritedPrivateMovable : PrivateMovable {
279+
InheritedPrivateMovable() = default;
280+
InheritedPrivateMovable(const InheritedPrivateMovable &) {}
281+
InheritedPrivateMovable(InheritedPrivateMovable &&) {}
282+
};
283+
284+
struct X1 {
285+
X1(const ProtectedMovable &M) : M(M) {}
286+
ProtectedMovable M;
287+
};
288+
289+
struct X2 {
290+
X2(const PrivateMovable &M) : M(M) {}
291+
PrivateMovable M;
292+
};
293+
294+
struct X3 {
295+
X3(const InheritedProtectedMovable &M) : M(M) {}
296+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
297+
// CHECK-FIXES: X3(InheritedProtectedMovable M) : M(std::move(M)) {}
298+
InheritedProtectedMovable M;
299+
};
300+
301+
struct X4 {
302+
X4(const InheritedPrivateMovable &M) : M(M) {}
303+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
304+
// CHECK-FIXES: X4(InheritedPrivateMovable M) : M(std::move(M)) {}
305+
InheritedPrivateMovable M;
306+
};
307+
308+
struct X5 {
309+
X5(const PrivateMovable &M) : M(M) {}
310+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
311+
// CHECK-FIXES: X5(PrivateMovable M) : M(std::move(M)) {}
312+
PrivateMovable M;
313+
};

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@ foreach(target armv6m-none-eabi;armv7m-none-eabi;armv7em-none-eabi;armv8m.main-n
362362
set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
363363
set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
364364
set(RUNTIMES_${target}_LIBCXX_SHARED_OUTPUT_NAME "c++-shared" CACHE STRING "")
365-
set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "")
366365
set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
367366
set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
368367
set(RUNTIMES_${target}_LIBCXX_ENABLE_LOCALIZATION OFF CACHE BOOL "")
@@ -376,6 +375,7 @@ foreach(target armv6m-none-eabi;armv7m-none-eabi;armv7em-none-eabi;armv8m.main-n
376375
set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
377376
set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
378377
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "")
378+
set(RUNTIMES_${target}_RUNTIMES_USE_LIBC "llvm-libc" CACHE STRING "")
379379

380380
# Enable FatLTO for baremetal runtimes
381381
set(RUNTIMES_${target}_LLVM_ENABLE_LTO OFF CACHE BOOL "")
@@ -417,7 +417,6 @@ foreach(target riscv32-unknown-elf)
417417
set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
418418
set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
419419
set(RUNTIMES_${target}_LIBCXX_SHARED_OUTPUT_NAME "c++-shared" CACHE STRING "")
420-
set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "")
421420
set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
422421
set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
423422
set(RUNTIMES_${target}_LIBCXX_ENABLE_LOCALIZATION OFF CACHE BOOL "")
@@ -431,6 +430,7 @@ foreach(target riscv32-unknown-elf)
431430
set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
432431
set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
433432
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "")
433+
set(RUNTIMES_${target}_RUNTIMES_USE_LIBC "llvm-libc" CACHE STRING "")
434434

435435
# Enable FatLTO for baremetal runtimes
436436
set(RUNTIMES_${target}_LLVM_ENABLE_LTO OFF CACHE BOOL "")

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ C++20 Feature Support
145145
- Fixed a crash with a defaulted spaceship (``<=>``) operator when the class
146146
contains a member declaration of vector type. Vector types cannot yet be
147147
compared directly, so this causes the operator to be deleted. (#GH137452)
148+
- Implement constant evaluation of lambdas that capture structured bindings.
149+
(#GH145956)
148150

149151
C++17 Feature Support
150152
^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/ExprConcepts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ class ExprRequirement : public Requirement {
310310
// TODO: Can we maybe not save the whole template parameter list and just
311311
// the type constraint? Saving the whole TPL makes it easier to handle in
312312
// serialization but is less elegant.
313+
ReturnTypeRequirement(TemplateParameterList *TPL, bool IsDependent);
313314
ReturnTypeRequirement(TemplateParameterList *TPL);
314315

315316
bool isDependent() const {

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include "clang/AST/DeclTemplate.h"
5656
#include "clang/AST/Expr.h"
5757
#include "clang/AST/ExprCXX.h"
58+
#include "clang/AST/ExprConcepts.h"
5859
#include "clang/AST/ExprObjC.h"
5960
#include "clang/AST/LambdaCapture.h"
6061
#include "clang/AST/NestedNameSpecifier.h"
@@ -1363,6 +1364,26 @@ extern const internal::VariadicDynCastAllOfMatcher<Decl, CXXDeductionGuideDecl>
13631364
extern const internal::VariadicDynCastAllOfMatcher<Decl, ConceptDecl>
13641365
conceptDecl;
13651366

1367+
/// Matches concept requirement.
1368+
///
1369+
/// Example matches 'requires(T p) { *p; }'
1370+
/// \code
1371+
/// template<typename T>
1372+
/// concept dereferencable = requires(T p) { *p; }
1373+
/// \endcode
1374+
extern const internal::VariadicDynCastAllOfMatcher<Expr, RequiresExpr>
1375+
requiresExpr;
1376+
1377+
/// Matches concept requirement body declaration.
1378+
///
1379+
/// Example matches '{ *p; }'
1380+
/// \code
1381+
/// template<typename T>
1382+
/// concept dereferencable = requires(T p) { *p; }
1383+
/// \endcode
1384+
extern const internal::VariadicDynCastAllOfMatcher<Decl, RequiresExprBodyDecl>
1385+
requiresExprBodyDecl;
1386+
13661387
/// Matches variable declarations.
13671388
///
13681389
/// Note: this does not match declarations of member variables, which are

clang/include/clang/Basic/AttrDocs.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,9 +1750,9 @@ to guard against use of uninitialized memory.
17501750

17511751
Rather, it is intended for use in "parameter-objects", used to simulate,
17521752
for example, the passing of named parameters.
1753-
The attribute generates a warning when explicit initializers for such
1754-
variables are not provided (this occurs regardless of whether any in-class field
1755-
initializers exist):
1753+
Except inside unevaluated contexts, the attribute generates a warning when
1754+
explicit initializers for such variables are not provided (this occurs
1755+
regardless of whether any in-class field initializers exist):
17561756

17571757
.. code-block:: c++
17581758

0 commit comments

Comments
 (0)