Skip to content

Commit d1bcda3

Browse files
committed
Merge branch 'main' into flang_builtin-mods
2 parents 4aa5b80 + 7a089bc commit d1bcda3

File tree

1,108 files changed

+87239
-106074
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,108 files changed

+87239
-106074
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/ClangTidy.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ namespace clang::tidy {
5555

5656
namespace {
5757
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
58+
#define ANALYZER_CHECK_NAME_PREFIX "clang-analyzer-"
5859
static constexpr llvm::StringLiteral AnalyzerCheckNamePrefix =
59-
"clang-analyzer-";
60+
ANALYZER_CHECK_NAME_PREFIX;
6061

6162
class AnalyzerDiagnosticConsumer : public ento::PathDiagnosticConsumer {
6263
public:
@@ -669,18 +670,19 @@ getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers) {
669670
Buffer.append(AnalyzerCheck);
670671
Result.Checks.insert(Buffer);
671672
}
672-
for (std::string OptionName : {
673+
674+
static constexpr llvm::StringLiteral OptionNames[] = {
673675
#define GET_CHECKER_OPTIONS
674676
#define CHECKER_OPTION(TYPE, CHECKER, OPTION_NAME, DESCRIPTION, DEFAULT, \
675677
RELEASE, HIDDEN) \
676-
Twine(AnalyzerCheckNamePrefix).concat(CHECKER ":" OPTION_NAME).str(),
678+
ANALYZER_CHECK_NAME_PREFIX CHECKER ":" OPTION_NAME,
677679

678680
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
679681
#undef CHECKER_OPTION
680682
#undef GET_CHECKER_OPTIONS
681-
}) {
682-
Result.Options.insert(OptionName);
683-
}
683+
};
684+
685+
Result.Options.insert_range(OptionNames);
684686
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
685687

686688
Context.setOptionsCollector(&Result.Options);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Clang MLIR generation
5959
| Bruno Cardoso Lopes
6060
| bruno.cardoso\@gmail.com (email), sonicsprawl (Discord), bcardosolopes (GitHub)
6161
62+
| Henrich Lauko
63+
| henrich.lau\@gmail.com (email), henrich.lauko (Discord), xlauko (GitHub)
6264
6365
Analysis & CFG
6466
~~~~~~~~~~~~~~

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: 12 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
^^^^^^^^^^^^^^^^^^^^^
@@ -660,6 +662,10 @@ Improvements to Clang's diagnostics
660662
#GH142457, #GH139913, #GH138850, #GH137867, #GH137860, #GH107840, #GH93308,
661663
#GH69470, #GH59391, #GH58172, #GH46215, #GH45915, #GH45891, #GH44490,
662664
#GH36703, #GH32903, #GH23312, #GH69874.
665+
666+
- Clang no longer emits a spurious -Wdangling-gsl warning in C++23 when
667+
iterating over an element of a temporary container in a range-based
668+
for loop.(#GH109793, #GH145164)
663669

664670
- Fixed false positives in ``-Wformat-truncation`` and ``-Wformat-overflow``
665671
diagnostics when floating-point numbers had both width field and plus or space
@@ -922,12 +928,17 @@ Bug Fixes to C++ Support
922928
- Fixed a crash when constant evaluating some explicit object member assignment operators. (#GH142835)
923929
- Fixed an access checking bug when substituting into concepts (#GH115838)
924930
- Fix a bug where private access specifier of overloaded function not respected. (#GH107629)
931+
- Correctly handles calling an explicit object member function template overload set
932+
through its address (``(&Foo::bar<baz>)()``).
925933
- Correctly handle allocations in the condition of a ``if constexpr``.(#GH120197) (#GH134820)
926934
- Fixed a crash when handling invalid member using-declaration in C++20+ mode. (#GH63254)
935+
- Fixed parsing of lambda expressions that appear after ``*`` or ``&`` in contexts where a declaration can appear. (#GH63880)
936+
- Fix name lookup in lambda appearing in the body of a requires expression. (#GH147650)
927937
- Fix a crash when trying to instantiate an ambiguous specialization. (#GH51866)
928938
- Improved handling of variables with ``consteval`` constructors, to
929939
consistently treat the initializer as manifestly constant-evaluated.
930940
(#GH135281)
941+
- Fix a crash in the presence of invalid base classes. (#GH147186)
931942

932943
Bug Fixes to AST Handling
933944
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1228,6 +1239,7 @@ OpenMP Support
12281239
- Fixed mapping of arrays of structs containing nested structs with user defined
12291240
mappers, by using compiler-generated default mappers for the outer structs for
12301241
such maps.
1242+
- Deprecation warning has been emitted for deprecated delimited form of ``declare target``.
12311243

12321244
Improvements
12331245
^^^^^^^^^^^^

clang/include/clang/AST/Decl.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,11 @@ class VarDecl : public DeclaratorDecl, public Redeclarable<VarDecl> {
10901090

10911091
LLVM_PREFERRED_TYPE(bool)
10921092
unsigned IsCXXCondDecl : 1;
1093+
1094+
/// Whether this variable is the implicit __range variable in a for-range
1095+
/// loop.
1096+
LLVM_PREFERRED_TYPE(bool)
1097+
unsigned IsCXXForRangeImplicitVar : 1;
10931098
};
10941099

10951100
union {
@@ -1591,6 +1596,19 @@ class VarDecl : public DeclaratorDecl, public Redeclarable<VarDecl> {
15911596
NonParmVarDeclBits.IsCXXCondDecl = true;
15921597
}
15931598

1599+
/// Whether this variable is the implicit '__range' variable in C++
1600+
/// range-based for loops.
1601+
bool isCXXForRangeImplicitVar() const {
1602+
return isa<ParmVarDecl>(this) ? false
1603+
: NonParmVarDeclBits.IsCXXForRangeImplicitVar;
1604+
}
1605+
1606+
void setCXXForRangeImplicitVar(bool FRV) {
1607+
assert(!isa<ParmVarDecl>(this) &&
1608+
"Cannot set IsCXXForRangeImplicitVar on ParmVarDecl");
1609+
NonParmVarDeclBits.IsCXXForRangeImplicitVar = FRV;
1610+
}
1611+
15941612
/// Determines if this variable's alignment is dependent.
15951613
bool hasDependentAlignment() const;
15961614

0 commit comments

Comments
 (0)