diff options
author | Randy MacLeod <Randy.MacLeod@windriver.com> | 2023-01-17 13:25:56 -0800 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2023-01-17 15:57:19 -0800 |
commit | fdb936e80b30f40cbf7ef9a8e124b58eec95f45c (patch) | |
tree | 1d9484f9ed5b9115cda31d8a6c7697fffdf9bb5e | |
parent | 8a6558fe1cedb3eb817333369a3cc2512364f1a6 (diff) | |
download | meta-clang-fdb936e80b30f40cbf7ef9a8e124b58eec95f45c.tar.gz |
Backport fix for no matching constructor
Fixes:
../../chrome/common/extensions/chrome_manifest_url_handlers.cc:101:7:
error: no matching constructor for initialization of 'std::map<const char *, std::reference_wrapper<const absl::optionalstd::string>>' (aka 'map<const char , reference_wrapper<const optional<basic_string>>>')
std::map<const char,
as seen with chromium-109:
https://github.com/OSSystems/meta-browser/issues/674
Thanks to Raphael Kubo da Costa for finding the commit to be backported!
Signed-off-by: Randy MacLeod <Randy.MacLeod@windriver.com>
-rw-r--r-- | recipes-devtools/clang/clang/0036-libc-LWG2993-reference_wrapper-T-conversion-from-U.patch | 379 | ||||
-rw-r--r-- | recipes-devtools/clang/common.inc | 1 |
2 files changed, 380 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0036-libc-LWG2993-reference_wrapper-T-conversion-from-U.patch b/recipes-devtools/clang/clang/0036-libc-LWG2993-reference_wrapper-T-conversion-from-U.patch new file mode 100644 index 0000000..aa9b2e7 --- /dev/null +++ b/recipes-devtools/clang/clang/0036-libc-LWG2993-reference_wrapper-T-conversion-from-U.patch | |||
@@ -0,0 +1,379 @@ | |||
1 | From eec04092d67b94f47439a9065b6bd4cd60165be2 Mon Sep 17 00:00:00 2001 | ||
2 | From: Arthur O'Dwyer <arthur.j.odwyer@gmail.com> | ||
3 | Date: Sat, 5 Dec 2020 19:37:41 -0500 | ||
4 | Subject: [PATCH] [libc++] [LWG2993] reference_wrapper<T> conversion from U&& | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | Implement the resolution of LWG2993. Replace a deleted constructor | ||
10 | with a constructor that SFINAEs away in appropriate circumstances. | ||
11 | Also, now that the constructor is templated, we must have an | ||
12 | explicit deduction guide to make CTAD work. | ||
13 | |||
14 | Some tests have been merged in from Agustín Bergé's D40259. | ||
15 | |||
16 | Differential Revision: https://reviews.llvm.org/D92725 | ||
17 | |||
18 | Upstream-Status: Backport | ||
19 | |||
20 | --- | ||
21 | libcxx/docs/Cxx2aStatusIssuesStatus.csv | 2 +- | ||
22 | libcxx/include/__functional_base | 21 ++++- | ||
23 | libcxx/include/functional | 7 +- | ||
24 | .../refwrap.assign/copy_assign.pass.cpp | 20 +++++ | ||
25 | .../refwrap/refwrap.const/deduct.pass.cpp | 31 +++++++ | ||
26 | .../refwrap.const/type_conv_ctor.pass.cpp | 81 +++++++++++++++++++ | ||
27 | .../refwrap.const/type_conv_ctor2.pass.cpp | 61 ++++++++++++++ | ||
28 | .../refwrap/refwrap.const/type_ctor.pass.cpp | 17 ++++ | ||
29 | 8 files changed, 234 insertions(+), 6 deletions(-) | ||
30 | create mode 100644 libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/deduct.pass.cpp | ||
31 | create mode 100644 libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp | ||
32 | create mode 100644 libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor2.pass.cpp | ||
33 | |||
34 | diff --git a/libcxx/docs/Cxx2aStatusIssuesStatus.csv b/libcxx/docs/Cxx2aStatusIssuesStatus.csv | ||
35 | index d2adde69d9d2..b411f12d0ce3 100644 | ||
36 | --- a/libcxx/docs/Cxx2aStatusIssuesStatus.csv | ||
37 | +++ b/libcxx/docs/Cxx2aStatusIssuesStatus.csv | ||
38 | @@ -35,7 +35,7 @@ | ||
39 | "`2981 <https://wg21.link/LWG2981>`__","Remove redundant deduction guides from standard library","Albuquerque","","" | ||
40 | "`2982 <https://wg21.link/LWG2982>`__","Making size_type consistent in associative container deduction guides","Albuquerque","","" | ||
41 | "`2988 <https://wg21.link/LWG2988>`__","Clause 32 cleanup missed one typename","Albuquerque","","" | ||
42 | -"`2993 <https://wg21.link/LWG2993>`__","reference_wrapper<T> conversion from T&&","Albuquerque","","" | ||
43 | +"`2993 <https://wg21.link/LWG2993>`__","reference_wrapper<T> conversion from T&&","Albuquerque","|Complete|","13.0" | ||
44 | "`2998 <https://wg21.link/LWG2998>`__","Requirements on function objects passed to {``forward_``,}list-specific algorithms","Albuquerque","|Nothing To Do|","" | ||
45 | "`3001 <https://wg21.link/LWG3001>`__","weak_ptr::element_type needs remove_extent_t","Albuquerque","","" | ||
46 | "`3024 <https://wg21.link/LWG3024>`__","variant's copies must be deleted instead of disabled via SFINAE","Albuquerque","|Complete|","" | ||
47 | diff --git a/libcxx/include/__functional_base b/libcxx/include/__functional_base | ||
48 | index 1c02e960d5f0..caa746036bf5 100644 | ||
49 | --- a/libcxx/include/__functional_base | ||
50 | +++ b/libcxx/include/__functional_base | ||
51 | @@ -380,13 +380,24 @@ public: | ||
52 | private: | ||
53 | type* __f_; | ||
54 | |||
55 | +#ifndef _LIBCPP_CXX03_LANG | ||
56 | + static void __fun(_Tp&) _NOEXCEPT; | ||
57 | + static void __fun(_Tp&&) = delete; | ||
58 | +#endif | ||
59 | + | ||
60 | public: | ||
61 | // construct/copy/destroy | ||
62 | - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | ||
63 | +#ifdef _LIBCPP_CXX03_LANG | ||
64 | + _LIBCPP_INLINE_VISIBILITY | ||
65 | reference_wrapper(type& __f) _NOEXCEPT | ||
66 | : __f_(_VSTD::addressof(__f)) {} | ||
67 | -#ifndef _LIBCPP_CXX03_LANG | ||
68 | - private: reference_wrapper(type&&); public: // = delete; // do not bind to temps | ||
69 | +#else | ||
70 | + template <class _Up, class = _EnableIf<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(_VSTD::declval<_Up>())) >> | ||
71 | + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | ||
72 | + reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(_VSTD::declval<_Up>()))) { | ||
73 | + type& __f = static_cast<_Up&&>(__u); | ||
74 | + __f_ = _VSTD::addressof(__f); | ||
75 | + } | ||
76 | #endif | ||
77 | |||
78 | // access | ||
79 | @@ -511,6 +522,10 @@ public: | ||
80 | #endif // _LIBCPP_CXX03_LANG | ||
81 | }; | ||
82 | |||
83 | +#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | ||
84 | +template <class _Tp> | ||
85 | +reference_wrapper(_Tp&) -> reference_wrapper<_Tp>; | ||
86 | +#endif | ||
87 | |||
88 | template <class _Tp> | ||
89 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | ||
90 | diff --git a/libcxx/include/functional b/libcxx/include/functional | ||
91 | index 67baa5bd4b77..f8565e7e6e67 100644 | ||
92 | --- a/libcxx/include/functional | ||
93 | +++ b/libcxx/include/functional | ||
94 | @@ -42,8 +42,8 @@ public: | ||
95 | typedef see below result_type; // Not always defined | ||
96 | |||
97 | // construct/copy/destroy | ||
98 | - reference_wrapper(T&) noexcept; | ||
99 | - reference_wrapper(T&&) = delete; // do not bind to temps | ||
100 | + template<class U> | ||
101 | + reference_wrapper(U&&); | ||
102 | reference_wrapper(const reference_wrapper<T>& x) noexcept; | ||
103 | |||
104 | // assignment | ||
105 | @@ -59,6 +59,9 @@ public: | ||
106 | operator() (ArgTypes&&...) const; | ||
107 | }; | ||
108 | |||
109 | +template <class T> | ||
110 | + reference_wrapper(T&) -> reference_wrapper<T>; | ||
111 | + | ||
112 | template <class T> reference_wrapper<T> ref(T& t) noexcept; | ||
113 | template <class T> void ref(const T&& t) = delete; | ||
114 | template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept; | ||
115 | diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp | ||
116 | index f82ee72de915..5058a7477581 100644 | ||
117 | --- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp | ||
118 | +++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp | ||
119 | @@ -21,6 +21,12 @@ class functor1 | ||
120 | { | ||
121 | }; | ||
122 | |||
123 | +struct convertible_to_int_ref { | ||
124 | + int val = 0; | ||
125 | + operator int&() { return val; } | ||
126 | + operator int const&() const { return val; } | ||
127 | +}; | ||
128 | + | ||
129 | template <class T> | ||
130 | void | ||
131 | test(T& t) | ||
132 | @@ -56,5 +62,19 @@ int main(int, char**) | ||
133 | const int j = 0; | ||
134 | test(j); | ||
135 | |||
136 | +#if TEST_STD_VER >= 11 | ||
137 | + convertible_to_int_ref convi; | ||
138 | + test(convi); | ||
139 | + convertible_to_int_ref const convic; | ||
140 | + test(convic); | ||
141 | + | ||
142 | + { | ||
143 | + using Ref = std::reference_wrapper<int>; | ||
144 | + static_assert((std::is_assignable<Ref&, int&>::value), ""); | ||
145 | + static_assert((!std::is_assignable<Ref&, int>::value), ""); | ||
146 | + static_assert((!std::is_assignable<Ref&, int&&>::value), ""); | ||
147 | + } | ||
148 | +#endif | ||
149 | + | ||
150 | return 0; | ||
151 | } | ||
152 | diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/deduct.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/deduct.pass.cpp | ||
153 | new file mode 100644 | ||
154 | index 000000000000..4e197e8fc3f3 | ||
155 | --- /dev/null | ||
156 | +++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/deduct.pass.cpp | ||
157 | @@ -0,0 +1,31 @@ | ||
158 | +//===----------------------------------------------------------------------===// | ||
159 | +// | ||
160 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
161 | +// See https://llvm.org/LICENSE.txt for license information. | ||
162 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
163 | +// | ||
164 | +//===----------------------------------------------------------------------===// | ||
165 | + | ||
166 | +// UNSUPPORTED: c++03, c++11, c++14 | ||
167 | +// UNSUPPORTED: libcpp-no-deduction-guides | ||
168 | + | ||
169 | +// <functional> | ||
170 | + | ||
171 | +// template <class T> | ||
172 | +// reference_wrapper(T&) -> reference_wrapper<T>; | ||
173 | + | ||
174 | +#include <functional> | ||
175 | + | ||
176 | +int main() | ||
177 | +{ | ||
178 | + int i = 0; | ||
179 | + std::reference_wrapper ri(i); | ||
180 | + static_assert(std::is_same_v<decltype(ri), std::reference_wrapper<int>>); | ||
181 | + std::reference_wrapper ri2(ri); | ||
182 | + static_assert(std::is_same_v<decltype(ri2), std::reference_wrapper<int>>); | ||
183 | + const int j = 0; | ||
184 | + std::reference_wrapper rj(j); | ||
185 | + static_assert(std::is_same_v<decltype(rj), std::reference_wrapper<const int>>); | ||
186 | + std::reference_wrapper rj2(rj); | ||
187 | + static_assert(std::is_same_v<decltype(rj2), std::reference_wrapper<const int>>); | ||
188 | +} | ||
189 | diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp | ||
190 | new file mode 100644 | ||
191 | index 000000000000..d8ad18215fb7 | ||
192 | --- /dev/null | ||
193 | +++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp | ||
194 | @@ -0,0 +1,81 @@ | ||
195 | +//===----------------------------------------------------------------------===// | ||
196 | +// | ||
197 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
198 | +// See https://llvm.org/LICENSE.txt for license information. | ||
199 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
200 | +// | ||
201 | +//===----------------------------------------------------------------------===// | ||
202 | + | ||
203 | +// UNSUPPORTED: c++03 | ||
204 | + | ||
205 | +// <functional> | ||
206 | +// | ||
207 | +// reference_wrapper | ||
208 | +// | ||
209 | +// template <class U> | ||
210 | +// reference_wrapper(U&&) noexcept(see below); | ||
211 | + | ||
212 | +#include <functional> | ||
213 | +#include <cassert> | ||
214 | + | ||
215 | +struct convertible_to_int_ref { | ||
216 | + int val = 0; | ||
217 | + operator int&() { return val; } | ||
218 | + operator int const&() const { return val; } | ||
219 | +}; | ||
220 | + | ||
221 | +template <bool IsNothrow> | ||
222 | +struct nothrow_convertible { | ||
223 | + int val = 0; | ||
224 | + operator int&() noexcept(IsNothrow) { return val; } | ||
225 | +}; | ||
226 | + | ||
227 | +struct convertible_from_int { | ||
228 | + convertible_from_int(int) {} | ||
229 | +}; | ||
230 | + | ||
231 | +void meow(std::reference_wrapper<int>) {} | ||
232 | +void meow(convertible_from_int) {} | ||
233 | + | ||
234 | +int gi; | ||
235 | +std::reference_wrapper<int> purr() { return gi; }; | ||
236 | + | ||
237 | +template <class T> | ||
238 | +void | ||
239 | +test(T& t) | ||
240 | +{ | ||
241 | + std::reference_wrapper<T> r(t); | ||
242 | + assert(&r.get() == &t); | ||
243 | +} | ||
244 | + | ||
245 | +void f() {} | ||
246 | + | ||
247 | +int main() | ||
248 | +{ | ||
249 | + convertible_to_int_ref convi; | ||
250 | + test(convi); | ||
251 | + convertible_to_int_ref const convic; | ||
252 | + test(convic); | ||
253 | + | ||
254 | + { | ||
255 | + using Ref = std::reference_wrapper<int>; | ||
256 | + static_assert((std::is_nothrow_constructible<Ref, nothrow_convertible<true>>::value), ""); | ||
257 | + static_assert((!std::is_nothrow_constructible<Ref, nothrow_convertible<false>>::value), ""); | ||
258 | + } | ||
259 | + | ||
260 | + { | ||
261 | + meow(0); | ||
262 | + (true) ? purr() : 0; | ||
263 | + } | ||
264 | + | ||
265 | +#ifdef __cpp_deduction_guides | ||
266 | + { | ||
267 | + int i = 0; | ||
268 | + std::reference_wrapper ri(i); | ||
269 | + static_assert((std::is_same<decltype(ri), std::reference_wrapper<int>>::value), "" ); | ||
270 | + const int j = 0; | ||
271 | + std::reference_wrapper rj(j); | ||
272 | + static_assert((std::is_same<decltype(rj), std::reference_wrapper<const int>>::value), "" ); | ||
273 | + } | ||
274 | +#endif | ||
275 | +} | ||
276 | diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor2.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor2.pass.cpp | ||
277 | new file mode 100644 | ||
278 | index 000000000000..debdc12c8588 | ||
279 | --- /dev/null | ||
280 | +++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor2.pass.cpp | ||
281 | @@ -0,0 +1,61 @@ | ||
282 | +//===----------------------------------------------------------------------===// | ||
283 | +// | ||
284 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
285 | +// See https://llvm.org/LICENSE.txt for license information. | ||
286 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
287 | +// | ||
288 | +//===----------------------------------------------------------------------===// | ||
289 | + | ||
290 | +// UNSUPPORTED: c++03 | ||
291 | + | ||
292 | +// <functional> | ||
293 | +// | ||
294 | +// reference_wrapper | ||
295 | +// | ||
296 | +// template <class U> | ||
297 | +// reference_wrapper(U&&); | ||
298 | + | ||
299 | +#include <functional> | ||
300 | +#include <cassert> | ||
301 | + | ||
302 | +struct B {} b; | ||
303 | + | ||
304 | +struct A1 { | ||
305 | + operator B& () const { return b; } | ||
306 | +}; | ||
307 | +struct A2 { | ||
308 | + operator B& () const noexcept { return b; } | ||
309 | +}; | ||
310 | + | ||
311 | +int main() | ||
312 | +{ | ||
313 | + { | ||
314 | + std::reference_wrapper<B> b1 = A1(); | ||
315 | + assert(&b1.get() == &b); | ||
316 | + b1 = A1(); | ||
317 | + assert(&b1.get() == &b); | ||
318 | + | ||
319 | + static_assert(std::is_convertible<A1, std::reference_wrapper<B>>::value, ""); | ||
320 | + static_assert(!std::is_nothrow_constructible<std::reference_wrapper<B>, A1>::value, ""); | ||
321 | +#if TEST_STD_VER >= 20 | ||
322 | + static_assert(!std::is_nothrow_convertible_v<A1, std::reference_wrapper<B>>); | ||
323 | +#endif | ||
324 | + static_assert(std::is_assignable<std::reference_wrapper<B>, A1>::value, ""); | ||
325 | + static_assert(!std::is_nothrow_assignable<std::reference_wrapper<B>, A1>::value, ""); | ||
326 | + } | ||
327 | + | ||
328 | + { | ||
329 | + std::reference_wrapper<B> b2 = A2(); | ||
330 | + assert(&b2.get() == &b); | ||
331 | + b2 = A2(); | ||
332 | + assert(&b2.get() == &b); | ||
333 | + | ||
334 | + static_assert(std::is_convertible<A2, std::reference_wrapper<B>>::value, ""); | ||
335 | + static_assert(std::is_nothrow_constructible<std::reference_wrapper<B>, A2>::value, ""); | ||
336 | +#if TEST_STD_VER >= 20 | ||
337 | + static_assert(std::is_nothrow_convertible_v<A2, std::reference_wrapper<B>>); | ||
338 | +#endif | ||
339 | + static_assert(std::is_assignable<std::reference_wrapper<B>, A2>::value, ""); | ||
340 | + static_assert(std::is_nothrow_assignable<std::reference_wrapper<B>, A2>::value, ""); | ||
341 | + } | ||
342 | +} | ||
343 | diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp | ||
344 | index 4d536a20411d..af2273452612 100644 | ||
345 | --- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp | ||
346 | +++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp | ||
347 | @@ -14,6 +14,7 @@ | ||
348 | |||
349 | #include <functional> | ||
350 | #include <cassert> | ||
351 | +#include <type_traits> | ||
352 | |||
353 | #include "test_macros.h" | ||
354 | |||
355 | @@ -43,5 +44,21 @@ int main(int, char**) | ||
356 | const int j = 0; | ||
357 | test(j); | ||
358 | |||
359 | + { | ||
360 | + using Ref = std::reference_wrapper<int>; | ||
361 | + static_assert((std::is_constructible<Ref, int&>::value), ""); | ||
362 | + static_assert((!std::is_constructible<Ref, int>::value), ""); | ||
363 | + static_assert((!std::is_constructible<Ref, int&&>::value), ""); | ||
364 | + } | ||
365 | + | ||
366 | +#if TEST_STD_VER >= 11 | ||
367 | + { | ||
368 | + using Ref = std::reference_wrapper<int>; | ||
369 | + static_assert((std::is_nothrow_constructible<Ref, int&>::value), ""); | ||
370 | + static_assert((!std::is_nothrow_constructible<Ref, int>::value), ""); | ||
371 | + static_assert((!std::is_nothrow_constructible<Ref, int&&>::value), ""); | ||
372 | + } | ||
373 | +#endif | ||
374 | + | ||
375 | return 0; | ||
376 | } | ||
377 | -- | ||
378 | 2.34.1 | ||
379 | |||
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc index 94619bd..6cedf4d 100644 --- a/recipes-devtools/clang/common.inc +++ b/recipes-devtools/clang/common.inc | |||
@@ -44,6 +44,7 @@ SRC_URI = "\ | |||
44 | file://0033-compiler-rt-Link-scudo-with-SANITIZER_CXX_ABI_LIBRAR.patch \ | 44 | file://0033-compiler-rt-Link-scudo-with-SANITIZER_CXX_ABI_LIBRAR.patch \ |
45 | file://0034-CMake-Installable-find-modules-for-terminfo-and-libf.patch \ | 45 | file://0034-CMake-Installable-find-modules-for-terminfo-and-libf.patch \ |
46 | file://0035-llvm-Do-not-use-standard-search-paths-in-find_librar.patch \ | 46 | file://0035-llvm-Do-not-use-standard-search-paths-in-find_librar.patch \ |
47 | file://0036-libc-LWG2993-reference_wrapper-T-conversion-from-U.patch \ | ||
47 | " | 48 | " |
48 | # Fallback to no-PIE if not set | 49 | # Fallback to no-PIE if not set |
49 | GCCPIE ??= "" | 50 | GCCPIE ??= "" |