Skip to content

Commit e6ea22f

Browse files
committed
Merge tag 'llvmorg-22.1.8' into rustc-llvm-21.1.8
LLVM 22.1.8
2 parents ec9ab9d + ca7933e commit e6ea22f

28 files changed

Lines changed: 779 additions & 63 deletions

File tree

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
file(GLOB files ${CPACK_TEMPORARY_INSTALL_DIRECTORY}/lib/*.a)
22

3+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
4+
set(strip_command
5+
${CPACK_TEMPORARY_INSTALL_DIRECTORY}/bin/llvm-bitcode-strip)
6+
set(strip_args -r)
7+
else()
8+
set(strip_command ${CPACK_TEMPORARY_INSTALL_DIRECTORY}/bin/llvm-strip)
9+
set(strip_args --no-strip-all -R .llvm.lto)
10+
endif()
11+
312
foreach(file ${files})
4-
execute_process(COMMAND ${CPACK_TEMPORARY_INSTALL_DIRECTORY}/bin/llvm-strip --no-strip-all -R .llvm.lto ${file})
13+
execute_process(COMMAND ${strip_command} ${strip_args} ${file} -o ${file})
514
endforeach()

clang/lib/Sema/SemaConcept.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ class HashParameterMapping : public RecursiveASTVisitor<HashParameterMapping> {
381381
return true;
382382
}
383383

384+
bool TraverseCXXThisExpr(CXXThisExpr *E) {
385+
return inherited::TraverseType(E->getType());
386+
}
387+
384388
bool TraverseTypeLoc(TypeLoc TL, bool TraverseQualifier = true) {
385389
// We don't care about TypeLocs. So traverse Types instead.
386390
return TraverseType(TL.getType().getCanonicalType(), TraverseQualifier);
@@ -394,6 +398,16 @@ class HashParameterMapping : public RecursiveASTVisitor<HashParameterMapping> {
394398
return true;
395399
}
396400

401+
bool TraverseUnresolvedUsingType(UnresolvedUsingType *T,
402+
bool TraverseQualifier) {
403+
// Sometimes the written type doesn't contain a qualifier which contains
404+
// necessary template arguments, whereas the declaration does.
405+
if (NestedNameSpecifier NNS = T->getDecl()->getQualifier();
406+
TraverseQualifier && NNS)
407+
return inherited::TraverseNestedNameSpecifier(NNS);
408+
return inherited::TraverseUnresolvedUsingType(T, TraverseQualifier);
409+
}
410+
397411
bool TraverseInjectedClassNameType(InjectedClassNameType *T,
398412
bool TraverseQualifier) {
399413
return TraverseTemplateArguments(T->getTemplateArgs(SemaRef.Context));

clang/test/SemaTemplate/concepts-using-decl.cpp

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,101 @@ struct child : base<int> {
197197
};
198198

199199
}
200+
201+
namespace GH198663 {
202+
203+
template <class T>
204+
concept HasIsTransparent = requires { typename T::is_transparent; };
205+
206+
template <class K, class V, class Compare>
207+
struct FlatMapBase {
208+
using key_compare = Compare;
209+
};
210+
211+
template <class K, class V, class Compare>
212+
struct FlatMap : FlatMapBase<K, V, Compare> {
213+
using Base = FlatMapBase<K, V, Compare>;
214+
215+
using typename Base::key_compare;
216+
217+
void at(const K&) {}
218+
void at(const K&) const {}
219+
template <class Other>
220+
void at(const Other&)
221+
requires HasIsTransparent<key_compare>
222+
{}
223+
template <class Other>
224+
void at(const Other&) const
225+
requires HasIsTransparent<key_compare>
226+
{}
227+
};
228+
229+
template <class T>
230+
struct Transparent {
231+
T t;
232+
};
233+
234+
struct TransparentComparator {
235+
using is_transparent = void;
236+
237+
template <class T>
238+
bool operator()(const T&, const Transparent<T>&) const;
239+
240+
template <class T>
241+
bool operator()(const Transparent<T>&, const T& t) const;
242+
243+
template <class T>
244+
bool operator()(const T&, const T&) const;
245+
};
246+
247+
struct NonTransparentComparator {
248+
template <class T>
249+
bool operator()(const T&, const Transparent<T>&) const;
250+
251+
template <class T>
252+
bool operator()(const Transparent<T>&, const T&) const;
253+
254+
template <class T>
255+
bool operator()(const T&, const T&) const;
256+
};
257+
258+
template <class M>
259+
concept CanAt = requires(M m, Transparent<int> k) { m.at(k); };
260+
261+
using TransparentMap = FlatMap<int, double, TransparentComparator>;
262+
using NonTransparentMap = FlatMap<int, double, NonTransparentComparator>;
263+
264+
static_assert(CanAt<TransparentMap>);
265+
266+
static_assert(!CanAt<NonTransparentMap>);
267+
268+
}
269+
270+
namespace GH198663_2 {
271+
272+
template<typename T>
273+
auto mv(T& t) -> T&&;
274+
275+
template<typename S, typename T>
276+
concept does_foo = requires(S s) {
277+
s.template foo<T>();
278+
};
279+
280+
template<typename S>
281+
struct type {
282+
S member;
283+
template<typename T>
284+
auto foo() -> T requires does_foo<decltype(mv(member)), T>;
285+
};
286+
287+
struct returns_int {
288+
template<typename T>
289+
auto foo() -> T;
290+
};
291+
292+
struct nothing {};
293+
294+
static_assert(does_foo<type<returns_int>&, int>);
295+
static_assert(not does_foo<type<nothing>&, int>);
296+
297+
}

cmake/Modules/LLVMVersion.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
77
set(LLVM_VERSION_MINOR 1)
88
endif()
99
if(NOT DEFINED LLVM_VERSION_PATCH)
10-
set(LLVM_VERSION_PATCH 7)
10+
set(LLVM_VERSION_PATCH 8)
1111
endif()
1212
if(NOT DEFINED LLVM_VERSION_SUFFIX)
1313
set(LLVM_VERSION_SUFFIX)

libcxx/include/__config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
3131
// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is
3232
// defined to XXYYZZ.
33-
# define _LIBCPP_VERSION 220107
33+
# define _LIBCPP_VERSION 220108
3434

3535
# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
3636
# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)

libcxx/include/optional

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,10 @@ private:
828828
template <class _Up>
829829
constexpr static bool __libcpp_opt_ref_ctor_deleted =
830830
is_lvalue_reference_v<_Tp> && reference_constructs_from_temporary_v<_Tp, _Up>;
831+
832+
template <class _Up>
833+
constexpr static bool __ref_ctor_enabled =
834+
is_lvalue_reference_v<_Tp> && !reference_constructs_from_temporary_v<_Tp, _Up>;
831835
# endif
832836

833837
// LWG2756: conditionally explicit conversion from _Up
@@ -935,15 +939,15 @@ public:
935939
template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0>
936940
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v)
937941
# if _LIBCPP_STD_VER >= 26
938-
noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up&>)
942+
noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, const _Up&>)
939943
# endif
940944
{
941945
this->__construct_from(__v);
942946
}
943947
template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0>
944948
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v)
945949
# if _LIBCPP_STD_VER >= 26
946-
noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up&>)
950+
noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, const _Up&>)
947951
# endif
948952
{
949953
this->__construct_from(__v);
@@ -981,25 +985,25 @@ public:
981985

982986
// optional(optional<U>& rhs)
983987
template <class _Up>
984-
requires(!__libcpp_opt_ref_ctor_deleted<_Up>) && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) &&
985-
(!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up&>
988+
requires __ref_ctor_enabled<_Up&> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && (!is_same_v<_Tp&, _Up>) &&
989+
is_constructible_v<_Tp&, _Up&>
986990
_LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up&, _Tp&>)
987991
optional(optional<_Up>& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, _Up&>) {
988992
this->__construct_from(__rhs);
989993
}
990994

991995
template <class _Up>
992-
requires __libcpp_opt_ref_ctor_deleted<_Up> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) &&
996+
requires __libcpp_opt_ref_ctor_deleted<_Up&> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) &&
993997
(!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up&>
994998
constexpr explicit optional(optional<_Up>& __rhs) noexcept = delete;
995999

9961000
// optional(const optional<U>&)
9971001
template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0>
998-
requires __libcpp_opt_ref_ctor_deleted<_Up>
1002+
requires __libcpp_opt_ref_ctor_deleted<const _Up&>
9991003
optional(const optional<_Up>&) = delete;
10001004

10011005
template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0>
1002-
requires __libcpp_opt_ref_ctor_deleted<_Up>
1006+
requires __libcpp_opt_ref_ctor_deleted<const _Up&>
10031007
explicit optional(const optional<_Up>&) = delete;
10041008

10051009
// optional(optional<U>&&)
@@ -1013,16 +1017,16 @@ public:
10131017

10141018
// optional(const optional<U>&&)
10151019
template <class _Up>
1016-
requires(!__libcpp_opt_ref_ctor_deleted<_Up>) && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) &&
1017-
(!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up>
1020+
requires __ref_ctor_enabled<const _Up> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) &&
1021+
(!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, const _Up>
10181022
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(!is_convertible_v<const _Up, _Tp&>)
10191023
optional(const optional<_Up>&& __v) noexcept(is_nothrow_constructible_v<_Tp&, const _Up>) {
10201024
this->__construct_from(std::move(__v));
10211025
}
10221026

10231027
template <class _Up>
1024-
requires __libcpp_opt_ref_ctor_deleted<_Up> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) &&
1025-
(!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up>
1028+
requires __libcpp_opt_ref_ctor_deleted<const _Up> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) &&
1029+
(!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, const _Up>
10261030
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>&& __v) noexcept = delete;
10271031
# endif
10281032

libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/const_optional_U.pass.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,37 @@ constexpr bool test_ref() {
151151
assert(*o2 == 1);
152152
}
153153

154+
{
155+
const std::optional<int> o1{2};
156+
std::optional<const int&> o2(o1);
157+
assert(*o2 == 2);
158+
assert(&(*o2) == &(*o1));
159+
}
160+
161+
{
162+
const std::optional<ReferenceConversion<int>> o1({1, 2});
163+
std::optional<const int&> o2(o1);
164+
assert(o2.has_value());
165+
assert(&(*o2) == &o1->lvalue);
166+
assert(*o2 == 1);
167+
}
168+
169+
{
170+
const std::optional<ReferenceConversion<int>> o1({1, 2});
171+
std::optional<const int&> o2(std::move(o1));
172+
assert(o2.has_value());
173+
assert(&(*o2) == &o1->rvalue);
174+
assert(*o2 == 2);
175+
}
176+
177+
{
178+
const std::optional<ReferenceConversionThrows<int>> o1({1, 2});
179+
ASSERT_NOT_NOEXCEPT(std::optional<const int&>(o1));
180+
ASSERT_NOT_NOEXCEPT(std::optional<const int&>(std::move(o1)));
181+
}
182+
183+
static_assert(!std::is_constructible_v<std::optional<int>, const std::optional<ConstRValueOnly<int>>&&>);
184+
154185
return true;
155186
}
156187
#endif

libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/optional_U.pass.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,36 @@ constexpr bool test_ref() {
144144
assert(*o2 == 1);
145145
}
146146

147+
{
148+
std::optional<int> o1(1);
149+
std::optional<const int&> o2(o1);
150+
assert(o2.has_value());
151+
assert(*o2 == 1);
152+
assert(&(*o2) == &(*o1));
153+
}
154+
155+
{
156+
std::optional<ReferenceConversion<int>> o1({1, 2});
157+
std::optional<const int&> o2(o1);
158+
assert(o2.has_value());
159+
assert(*o2 == 1);
160+
assert(&(*o2) == &o1->lvalue);
161+
}
162+
163+
{
164+
std::optional<ReferenceConversion<int>> o1({1, 2});
165+
std::optional<const int&> o2(std::move(o1));
166+
assert(o2.has_value());
167+
assert(*o2 == 2);
168+
assert(&(*o2) == &o1->rvalue);
169+
}
170+
171+
{
172+
std::optional<ReferenceConversionThrows<int>> o1({1, 2});
173+
ASSERT_NOT_NOEXCEPT(std::optional<const int&>(o1));
174+
ASSERT_NOT_NOEXCEPT(std::optional<const int&>(std::move(o1)));
175+
}
176+
147177
return true;
148178
}
149179
#endif
@@ -164,6 +194,11 @@ int main(int, char**) {
164194
test<Z>(std::move(rhs), true);
165195
}
166196

197+
#if TEST_STD_VER >= 26
198+
// GH: #194415
199+
static_assert(!std::is_constructible_v<std::optional<int>, std::optional<LValueOnly<int>>&>);
200+
#endif
201+
167202
static_assert(!(std::is_constructible<optional<X>, optional<Z>>::value), "");
168203

169204
#if TEST_STD_VER >= 26

libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/ref_constructs_from_temporary.verify.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ void test() {
2929
const std::optional<int> co(1);
3030
std::optional<int> o0(1);
3131

32-
// expected-error-re@*:* 10 {{call to deleted constructor of 'std::optional<{{.*}}>'}}
32+
// expected-error-re@*:* 8 {{call to deleted constructor of 'std::optional<{{.*}}>'}}
3333
std::optional<const int&> o1{1}; // optional(U&&)
34-
std::optional<const int&> o2{o0}; // optional(optional<U>&)
35-
std::optional<const int&> o3{co}; // optional(const optional<U>&)
36-
std::optional<const int&> o4{std::move(o0)}; // optional(optional<U>&&&)
37-
std::optional<const int&> o5{std::move(co)}; // optional(optional<U>&&&)
34+
std::optional<const int&> o4{std::move(o0)}; // optional(optional<U>&&)
35+
std::optional<const int&> o5{std::move(co)}; // optional(optional<U>&&)
3836

3937
std::optional<const X&> o6{1}; // optional(U&&)
4038
std::optional<const X&> o7{o0}; // optional(optional<U>&)

0 commit comments

Comments
 (0)