Skip to content

Commit 5181898

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:211eebf44fb7076d59c2d683d9211f9d44e50cce into amd-gfx:b31cbbde5500
Local branch amd-gfx b31cbbd Merged main:d7e28cd82bd3141093f96f7ce2e7b36f1b115fad into amd-gfx:0b79b4caf568 Remote branch main 211eebf [libc++][ranges] remove `__workaround_52970` (llvm#85683)
2 parents b31cbbd + 211eebf commit 5181898

File tree

30 files changed

+334
-104
lines changed

30 files changed

+334
-104
lines changed

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ struct CodeCompletionBuilder {
619619
}
620620
// 'CompletionItemKind::Interface' matches template type aliases.
621621
if (Completion.Kind == CompletionItemKind::Interface ||
622-
Completion.Kind == CompletionItemKind::Class) {
622+
Completion.Kind == CompletionItemKind::Class ||
623+
Completion.Kind == CompletionItemKind::Variable) {
623624
if (Snippet->front() != '<')
624625
return *Snippet; // Not an arg snippet?
625626

clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2648,12 +2648,15 @@ TEST(CompletionTest, CompletionFunctionArgsDisabled) {
26482648
class foo_class{};
26492649
template <class T>
26502650
using foo_alias = T**;
2651+
template <class T>
2652+
T foo_var = T{};
26512653
void f() { foo_^ })cpp",
26522654
{}, Opts);
26532655
EXPECT_THAT(
26542656
Results.Completions,
26552657
UnorderedElementsAre(AllOf(named("foo_class"), snippetSuffix("<$0>")),
2656-
AllOf(named("foo_alias"), snippetSuffix("<$0>"))));
2658+
AllOf(named("foo_alias"), snippetSuffix("<$0>")),
2659+
AllOf(named("foo_var"), snippetSuffix("<$0>"))));
26572660
}
26582661
{
26592662
auto Results = completions(
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- StdSpecialSymbolMap.inc -----------------------------------*- C -*-===//
2+
//
3+
// This is a hand-curated list for C symbols that cannot be parsed/extracted
4+
// via the include-mapping tool (gen_std.py).
5+
//
6+
//===----------------------------------------------------------------------===//
7+
8+
SYMBOL(size_t, None, <stddef.h>)
9+
SYMBOL(size_t, None, <stdio.h>)
10+
SYMBOL(size_t, None, <stdlib.h>)
11+
SYMBOL(size_t, None, <string.h>)
12+
SYMBOL(size_t, None, <time.h>)
13+
SYMBOL(size_t, None, <uchar.h>)
14+
SYMBOL(size_t, None, <wchar.h>)

clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ static const SymbolHeaderMapping *getMappingPerLang(Lang L) {
5555
}
5656

5757
static int countSymbols(Lang Language) {
58-
ArrayRef<const char*> Symbols;
58+
ArrayRef<const char *> Symbols;
5959
#define SYMBOL(Name, NS, Header) #NS #Name,
6060
switch (Language) {
6161
case Lang::C: {
6262
static constexpr const char *CSymbols[] = {
63+
#include "CSpecialSymbolMap.inc"
6364
#include "CSymbolMap.inc"
6465
};
6566
Symbols = CSymbols;
@@ -147,6 +148,7 @@ static int initialize(Lang Language) {
147148
switch (Language) {
148149
case Lang::C: {
149150
static constexpr Symbol CSymbols[] = {
151+
#include "CSpecialSymbolMap.inc"
150152
#include "CSymbolMap.inc"
151153
};
152154
for (const Symbol &S : CSymbols)

clang/unittests/Tooling/StandardLibraryTest.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,19 @@ TEST(StdlibTest, RecognizerForC99) {
185185
stdlib::Symbol::named("", "uint8_t", stdlib::Lang::C));
186186
}
187187

188+
TEST(StdlibTest, SpecialCMappings) {
189+
TestInputs Input("typedef char size_t;");
190+
Input.Language = TestLanguage::Lang_C99;
191+
TestAST AST(Input);
192+
193+
auto &SizeT = lookup(AST, "size_t");
194+
stdlib::Recognizer Recognizer;
195+
auto ActualSym = Recognizer(&SizeT);
196+
assert(ActualSym);
197+
EXPECT_EQ(ActualSym, stdlib::Symbol::named("", "size_t", stdlib::Lang::C));
198+
EXPECT_EQ(ActualSym->header()->name(), "<stddef.h>");
199+
}
200+
188201
} // namespace
189202
} // namespace tooling
190203
} // namespace clang

libcxx/docs/Status/Cxx23Issues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
"`3711 <https://wg21.link/LWG3711>`__","Missing preconditions for slide_view constructor","July 2022","","","|ranges|"
182182
"`3712 <https://wg21.link/LWG3712>`__","``chunk_view`` and ``slide_view`` should not be ``default_initializable``","July 2022","","","|ranges|"
183183
"`3713 <https://wg21.link/LWG3713>`__","Sorted with respect to comparator (only)","July 2022","",""
184-
"`3715 <https://wg21.link/LWG3715>`__","``view_interface::empty`` is overconstrained","July 2022","","","|ranges|"
184+
"`3715 <https://wg21.link/LWG3715>`__","``view_interface::empty`` is overconstrained","July 2022","|Complete|","19.0","|ranges|"
185185
"`3719 <https://wg21.link/LWG3719>`__","Directory iterators should be usable with default sentinel","July 2022","|Complete|","17.0","|ranges|"
186186
"`3721 <https://wg21.link/LWG3721>`__","Allow an ``arg-id`` with a value of zero for ``width`` in ``std-format-spec``","July 2022","|Complete|","16.0","|format|"
187187
"`3724 <https://wg21.link/LWG3724>`__","``decay-copy`` should be constrained","July 2022","|Complete|","14.0"

libcxx/include/__concepts/class_or_enum.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2828
template <class _Tp>
2929
concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>;
3030

31-
// Work around Clang bug https://llvm.org/PR52970
32-
// TODO: remove this workaround once libc++ no longer has to support Clang 13 (it was fixed in Clang 14).
33-
template <class _Tp>
34-
concept __workaround_52970 = is_class_v<__remove_cvref_t<_Tp>> || is_union_v<__remove_cvref_t<_Tp>>;
35-
3631
#endif // _LIBCPP_STD_VER >= 20
3732

3833
_LIBCPP_END_NAMESPACE_STD

libcxx/include/__format/format_arg_store.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ consteval __arg_t __determine_arg_t() {
151151
// The overload for not formattable types allows triggering the static
152152
// assertion below.
153153
template <class _Context, class _Tp>
154-
requires(!__formattable<_Tp, typename _Context::char_type>)
154+
requires(!__formattable_with<_Tp, _Context>)
155155
consteval __arg_t __determine_arg_t() {
156156
return __arg_t::__none;
157157
}
@@ -165,7 +165,6 @@ _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __valu
165165
using _Dp = remove_const_t<_Tp>;
166166
constexpr __arg_t __arg = __determine_arg_t<_Context, _Dp>();
167167
static_assert(__arg != __arg_t::__none, "the supplied type is not formattable");
168-
169168
static_assert(__formattable_with<_Tp, _Context>);
170169

171170
// Not all types can be used to directly initialize the

libcxx/include/__ranges/access.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ concept __can_borrow = is_lvalue_reference_v<_Tp> || enable_borrowed_range<remov
4141
namespace ranges {
4242
namespace __begin {
4343
template <class _Tp>
44-
concept __member_begin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
44+
concept __member_begin = __can_borrow<_Tp> && requires(_Tp&& __t) {
4545
{ _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator;
4646
};
4747

@@ -103,7 +103,7 @@ using iterator_t = decltype(ranges::begin(std::declval<_Tp&>()));
103103
namespace ranges {
104104
namespace __end {
105105
template <class _Tp>
106-
concept __member_end = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
106+
concept __member_end = __can_borrow<_Tp> && requires(_Tp&& __t) {
107107
typename iterator_t<_Tp>;
108108
{ _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp>>;
109109
};

libcxx/include/__ranges/data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ template <class _Tp>
4040
concept __ptr_to_object = is_pointer_v<_Tp> && is_object_v<remove_pointer_t<_Tp>>;
4141

4242
template <class _Tp>
43-
concept __member_data = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
43+
concept __member_data = __can_borrow<_Tp> && requires(_Tp&& __t) {
4444
{ _LIBCPP_AUTO_CAST(__t.data()) } -> __ptr_to_object;
4545
};
4646

libcxx/include/__ranges/empty.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929
namespace ranges {
3030
namespace __empty {
3131
template <class _Tp>
32-
concept __member_empty = __workaround_52970<_Tp> && requires(_Tp&& __t) { bool(__t.empty()); };
32+
concept __member_empty = requires(_Tp&& __t) { bool(__t.empty()); };
3333

3434
template <class _Tp>
3535
concept __can_invoke_size = !__member_empty<_Tp> && requires(_Tp&& __t) { ranges::size(__t); };

libcxx/include/__ranges/rbegin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3636
namespace ranges {
3737
namespace __rbegin {
3838
template <class _Tp>
39-
concept __member_rbegin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
39+
concept __member_rbegin = __can_borrow<_Tp> && requires(_Tp&& __t) {
4040
{ _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator;
4141
};
4242

libcxx/include/__ranges/rend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3737
namespace ranges {
3838
namespace __rend {
3939
template <class _Tp>
40-
concept __member_rend = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
40+
concept __member_rend = __can_borrow<_Tp> && requires(_Tp&& __t) {
4141
ranges::rbegin(__t);
4242
{ _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
4343
};

libcxx/include/__ranges/size.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ template <class _Tp>
4747
concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>;
4848

4949
template <class _Tp>
50-
concept __member_size = __size_enabled<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
50+
concept __member_size = __size_enabled<_Tp> && requires(_Tp&& __t) {
5151
{ _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like;
5252
};
5353

libcxx/include/__ranges/view_interface.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <__ranges/access.h>
2222
#include <__ranges/concepts.h>
2323
#include <__ranges/empty.h>
24+
#include <__ranges/size.h>
2425
#include <__type_traits/is_class.h>
2526
#include <__type_traits/make_unsigned.h>
2627
#include <__type_traits/remove_cv.h>
@@ -51,16 +52,24 @@ class view_interface {
5152
public:
5253
template <class _D2 = _Derived>
5354
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty()
54-
requires forward_range<_D2>
55+
requires sized_range<_D2> || forward_range<_D2>
5556
{
56-
return ranges::begin(__derived()) == ranges::end(__derived());
57+
if constexpr (sized_range<_D2>) {
58+
return ranges::size(__derived()) == 0;
59+
} else {
60+
return ranges::begin(__derived()) == ranges::end(__derived());
61+
}
5762
}
5863

5964
template <class _D2 = _Derived>
6065
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const
61-
requires forward_range<const _D2>
66+
requires sized_range<const _D2> || forward_range<const _D2>
6267
{
63-
return ranges::begin(__derived()) == ranges::end(__derived());
68+
if constexpr (sized_range<const _D2>) {
69+
return ranges::size(__derived()) == 0;
70+
} else {
71+
return ranges::begin(__derived()) == ranges::end(__derived());
72+
}
6473
}
6574

6675
template <class _D2 = _Derived>

libcxx/modules/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,15 @@ add_custom_target(generate-cxx-modules
206206
# Configure the modules manifest.
207207
# Use the relative path between the installation and the module in the json
208208
# file. This allows moving the entire installation to a different location.
209+
cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_LIBRARY_DIR
210+
BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}
211+
OUTPUT_VARIABLE ABS_LIBRARY_DIR)
212+
cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_MODULES_DIR
213+
BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}
214+
OUTPUT_VARIABLE ABS_MODULES_DIR)
209215
file(RELATIVE_PATH LIBCXX_MODULE_RELATIVE_PATH
210-
${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_LIBRARY_DIR}
211-
${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_MODULES_DIR})
216+
${ABS_LIBRARY_DIR}
217+
${ABS_MODULES_DIR})
212218
configure_file(
213219
"modules.json.in"
214220
"${LIBCXX_LIBRARY_DIR}/libc++.modules.json"

libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ struct InputRange : std::ranges::view_interface<InputRange> {
3939
constexpr InputIter end() const { return InputIter(buff + 8); }
4040
};
4141

42+
struct SizedInputRange : std::ranges::view_interface<SizedInputRange> {
43+
int buff[8] = {0, 1, 2, 3, 4, 5, 6, 7};
44+
constexpr InputIter begin() const { return InputIter(buff); }
45+
constexpr sentinel_wrapper<InputIter> end() const { return sentinel_wrapper(InputIter(buff + 8)); }
46+
constexpr std::size_t size() const { return 8; }
47+
};
48+
static_assert(std::ranges::sized_range<SizedInputRange>);
49+
4250
struct NotSizedSentinel {
4351
using value_type = int;
4452
using difference_type = std::ptrdiff_t;
@@ -155,11 +163,24 @@ concept BoolOpInvocable = requires (T const& obj) { bool(obj); };
155163

156164
constexpr bool testEmpty() {
157165
static_assert(!EmptyInvocable<InputRange>);
166+
// LWG 3715: `view_interface::empty` is overconstrained
167+
static_assert(EmptyInvocable<SizedInputRange>);
158168
static_assert( EmptyInvocable<ForwardRange>);
159169

160170
static_assert(!BoolOpInvocable<InputRange>);
171+
static_assert(BoolOpInvocable<SizedInputRange>);
161172
static_assert( BoolOpInvocable<ForwardRange>);
162173

174+
SizedInputRange sizedInputRange;
175+
assert(!sizedInputRange.empty());
176+
assert(!static_cast<SizedInputRange const&>(sizedInputRange).empty());
177+
178+
assert(sizedInputRange);
179+
assert(static_cast<SizedInputRange const&>(sizedInputRange));
180+
181+
assert(!std::ranges::empty(sizedInputRange));
182+
assert(!std::ranges::empty(static_cast<SizedInputRange const&>(sizedInputRange)));
183+
163184
ForwardRange forwardRange;
164185
assert(!forwardRange.empty());
165186
assert(!static_cast<ForwardRange const&>(forwardRange).empty());
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//===----------------------------------------------------------------------===//
2+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3+
// See https://llvm.org/LICENSE.txt for license information.
4+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
//
6+
//===----------------------------------------------------------------------===//
7+
8+
// UNSUPPORTED: c++03, c++11, c++14, c++17
9+
10+
// XFAIL: availability-fp_to_chars-missing
11+
12+
// The sample code is based on the bug report
13+
// https://github.com/llvm/llvm-project/issues/81590
14+
//
15+
// Tests whether this formatter does not fail to compile due to nested concept
16+
// evaluation.
17+
18+
#include <format>
19+
#include <variant>
20+
21+
struct X : std::variant<X*> {
22+
X* p = nullptr;
23+
constexpr const std::variant<X*>& decay() const noexcept { return *this; }
24+
};
25+
26+
template <>
27+
struct std::formatter<X, char> : std::formatter<std::string, char> {
28+
static constexpr auto format(const X& x, auto ctx) {
29+
if (!x.p)
30+
return ctx.out();
31+
auto m = [&](const X* t) { return std::format_to(ctx.out(), "{}", *t); };
32+
return std::visit(m, x.decay());
33+
}
34+
};
35+
36+
void bug_81590() { (void)std::format("{}", X{}); }

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 493292
19+
#define LLVM_MAIN_REVISION 493304
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/Analysis/TargetLibraryInfo.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -560,16 +560,12 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
560560
break;
561561
case Triple::Linux:
562562
// exp10, exp10f, exp10l is available on Linux (GLIBC) but are extremely
563-
// buggy prior to glibc version 2.18. Until this version is widely deployed
564-
// or we have a reasonable detection strategy, we cannot use exp10 reliably
565-
// on Linux.
566-
//
567-
// Fall through to disable all of them.
568-
[[fallthrough]];
569-
default:
570-
TLI.setUnavailable(LibFunc_exp10);
571-
TLI.setUnavailable(LibFunc_exp10f);
572-
TLI.setUnavailable(LibFunc_exp10l);
563+
// buggy prior to glibc version 2.18. As this version is so old, we
564+
// don't really need to worry about using exp10 on Linux.
565+
TLI.setAvailableWithName(LibFunc_exp10, "__exp10");
566+
TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f");
567+
TLI.setAvailableWithName(LibFunc_exp10l, "__exp10l");
568+
break;
573569
}
574570

575571
// ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and
@@ -841,6 +837,9 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
841837
TLI.setUnavailable(LibFunc_strndup);
842838
TLI.setUnavailable(LibFunc_strnlen);
843839
TLI.setUnavailable(LibFunc_toascii);
840+
TLI.setUnavailable(LibFunc_exp10);
841+
TLI.setUnavailable(LibFunc_exp10f);
842+
TLI.setUnavailable(LibFunc_exp10l);
844843
}
845844

846845
// As currently implemented in clang, NVPTX code has no standard library to

0 commit comments

Comments
 (0)