Skip to content

Commit

Permalink
Merged main:0e8208eca1c316b7302de7803ab0d85a1dd77076 into amd-gfx:4ce…
Browse files Browse the repository at this point in the history
…515f18a36

Local branch amd-gfx 4ce515f Merged main:69c43468d3f21df6232fda0530f03f18b0f40345 into amd-gfx:45ac84d24a03
Remote branch main 0e8208e [libc++] Run the Lit test suite against an installed version of the library (llvm#96910)
  • Loading branch information
SC llvm team authored and SC llvm team committed Aug 28, 2024
2 parents 4ce515f + 0e8208e commit 0447d31
Show file tree
Hide file tree
Showing 135 changed files with 2,173 additions and 1,062 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/libcxx-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest-stable'
xcode-version: 'latest'
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Build and test
run: |
Expand Down
11 changes: 7 additions & 4 deletions clang/docs/UsersManual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -950,10 +950,13 @@ treated as a file name and is searched for sequentially in the directories:
- system directory,
- the directory where Clang executable resides.

Both user and system directories for configuration files are specified during
clang build using CMake parameters, ``CLANG_CONFIG_FILE_USER_DIR`` and
``CLANG_CONFIG_FILE_SYSTEM_DIR`` respectively. The first file found is used.
It is an error if the required file cannot be found.
Both user and system directories for configuration files can be specified
either during build or during runtime. At build time, use
``CLANG_CONFIG_FILE_USER_DIR`` and ``CLANG_CONFIG_FILE_SYSTEM_DIR``. At run
time use the ``--config-user-dir=`` and ``--config-system-dir=`` command line
options. Specifying config directories at runtime overrides the config
directories set at build time The first file found is used. It is an error if
the required file cannot be found.

The default configuration files are searched for in the same directories
following the rules described in the next paragraphs. Loading default
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2537,7 +2537,7 @@ inline bool ArrayDecay(InterpState &S, CodePtr OpPC) {
if (!CheckRange(S, OpPC, Ptr, CSK_ArrayToPointer))
return false;

if (Ptr.isRoot() || !Ptr.isUnknownSizeArray() || Ptr.isDummy()) {
if (Ptr.isRoot() || !Ptr.isUnknownSizeArray()) {
S.Stk.push<Pointer>(Ptr.atIndex(0));
return true;
}
Expand Down
8 changes: 6 additions & 2 deletions clang/lib/Format/UnwrappedLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3992,6 +3992,9 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
auto IsNonMacroIdentifier = [](const FormatToken *Tok) {
return Tok->is(tok::identifier) && Tok->TokenText != Tok->TokenText.upper();
};
// JavaScript/TypeScript supports anonymous classes like:
// a = class extends foo { }
bool JSPastExtendsOrImplements = false;
// The actual identifier can be a nested name specifier, and in macros
// it is often token-pasted.
// An [[attribute]] can be before the identifier.
Expand All @@ -4002,6 +4005,7 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
FormatTok->isOneOf(tok::period, tok::comma))) {
if (Style.isJavaScript() &&
FormatTok->isOneOf(Keywords.kw_extends, Keywords.kw_implements)) {
JSPastExtendsOrImplements = true;
// JavaScript/TypeScript supports inline object types in
// extends/implements positions:
// class Foo implements {bar: number} { }
Expand All @@ -4027,8 +4031,8 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
case tok::coloncolon:
break;
default:
if (!ClassName && Previous->is(tok::identifier) &&
Previous->isNot(TT_AttributeMacro)) {
if (!JSPastExtendsOrImplements && !ClassName &&
Previous->is(tok::identifier) && Previous->isNot(TT_AttributeMacro)) {
ClassName = Previous;
}
}
Expand Down
9 changes: 9 additions & 0 deletions clang/test/AST/ByteCode/arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,15 @@ namespace Incomplete {
constexpr int C = *F.a; // both-error {{must be initialized by a constant expression}} \
// both-note {{array-to-pointer decay of array member without known bound}}

struct X {
int a;
int b[];
};
extern X x;
constexpr int *xb = x.b; // both-error {{must be initialized by a constant expression}} \
// both-note {{array-to-pointer decay of array member without known bound}}


/// These are from test/SemaCXX/constant-expression-cxx11.cpp
extern int arr[];
constexpr int *c = &arr[1]; // both-error {{must be initialized by a constant expression}} \
Expand Down
8 changes: 8 additions & 0 deletions clang/unittests/Format/FormatTestJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,14 @@ TEST_F(FormatTestJS, GoogScopes) {
"});");
}

TEST_F(FormatTestJS, GoogAnonymousClass) {
verifyFormat("a = class extends goog.structs.a {\n"
" a() {\n"
" return 0;\n"
" }\n"
"};");
}

TEST_F(FormatTestJS, IIFEs) {
// Internal calling parens; no semi.
verifyFormat("(function() {\n"
Expand Down
6 changes: 6 additions & 0 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3238,6 +3238,12 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
EXPECT_BRACE_KIND(Tokens[8], BK_BracedInit);
EXPECT_BRACE_KIND(Tokens[11], BK_BracedInit);
EXPECT_BRACE_KIND(Tokens[13], BK_Block);

Tokens = annotate("a = class extends goog.a {};",
getGoogleStyle(FormatStyle::LK_JavaScript));
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_ClassLBrace);
EXPECT_BRACE_KIND(Tokens[7], BK_Block);
}

TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) {
Expand Down
2 changes: 1 addition & 1 deletion libc/cmake/modules/prepare_libc_gpu_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if(DEFINED LLVM_TARGETS_TO_BUILD AND LIBC_TARGET_ARCHITECTURE_IS_AMDGPU
AND NOT "AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD)
set(LIBC_GPU_TESTS_DISABLED TRUE)
message(STATUS "AMDGPU backend is not available, tests will not be built")
elseif(DEFINED LLVM_TARGETS_TO_BUILD AND LIBC_TARGET_ARCHITECTURE_IS_AMDGPU
elseif(DEFINED LLVM_TARGETS_TO_BUILD AND LIBC_TARGET_ARCHITECTURE_IS_NVPTX
AND NOT "NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
set(LIBC_GPU_TESTS_DISABLED TRUE)
message(STATUS "NVPTX backend is not available, tests will not be built")
Expand Down
2 changes: 2 additions & 0 deletions libc/config/gpu/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdio.asprintf
libc.src.stdio.vasprintf
libc.src.stdio.scanf
libc.src.stdio.vscanf
libc.src.stdio.fscanf
libc.src.stdio.vfscanf
libc.src.stdio.sscanf
libc.src.stdio.vsscanf
libc.src.stdio.feof
Expand Down
56 changes: 30 additions & 26 deletions libc/test/src/stdio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,33 +272,37 @@ if(LLVM_LIBC_FULL_BUILD)
)
endif()

add_libc_test(
fscanf_test
SUITE
libc_stdio_unittests
SRCS
fscanf_test.cpp
DEPENDS
libc.src.stdio.fscanf
${fscanf_test_deps}
libc.src.__support.CPP.string_view
COMPILE_OPTIONS
${use_system_file}
)
# FIXME: These tests currently fail on AMDGPU due to an optimization bug in the
# `amdgpu-attributor` pass. Disable until that's fixed.
if(NOT LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
add_libc_test(
fscanf_test
SUITE
libc_stdio_unittests
SRCS
fscanf_test.cpp
DEPENDS
libc.src.stdio.fscanf
${fscanf_test_deps}
libc.src.__support.CPP.string_view
COMPILE_OPTIONS
${use_system_file}
)

add_libc_test(
vfscanf_test
SUITE
libc_stdio_unittests
SRCS
vfscanf_test.cpp
DEPENDS
libc.src.stdio.vfscanf
${fscanf_test_deps}
libc.src.__support.CPP.string_view
COMPILE_OPTIONS
${use_system_file}
)
add_libc_test(
vfscanf_test
SUITE
libc_stdio_unittests
SRCS
vfscanf_test.cpp
DEPENDS
libc.src.stdio.vfscanf
${fscanf_test_deps}
libc.src.__support.CPP.string_view
COMPILE_OPTIONS
${use_system_file}
)
endif()

if(LIBC_CONF_SCANF_DISABLE_FLOAT)
list(APPEND sscanf_test_copts "-DLIBC_COPT_SCANF_DISABLE_FLOAT")
Expand Down
6 changes: 5 additions & 1 deletion libcxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ option(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-gcc.cfg.in")
elseif(MINGW)
set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-mingw.cfg.in")
if (LIBCXX_ENABLE_SHARED)
set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-mingw.cfg.in")
else()
set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-static-mingw.cfg.in")
endif()
elseif(WIN32) # clang-cl
if (LIBCXX_ENABLE_SHARED)
set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-clangcl.cfg.in")
Expand Down
1 change: 1 addition & 0 deletions libcxx/cmake/caches/Apple.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "")
set(CMAKE_INSTALL_NAME_DIR "/usr/lib" CACHE STRING "")
set(CMAKE_POSITION_INDEPENDENT_CODE OFF CACHE BOOL "")

set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
Expand Down
4 changes: 3 additions & 1 deletion libcxx/docs/FeatureTestMacroTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_polymorphic_allocator`` ``201902L``
---------------------------------------------------------- -----------------
``__cpp_lib_ranges`` ``202207L``
``__cpp_lib_ranges`` ``202110L``
---------------------------------------------------------- -----------------
``__cpp_lib_remove_cvref`` ``201711L``
---------------------------------------------------------- -----------------
Expand Down Expand Up @@ -350,6 +350,8 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_print`` ``202207L``
---------------------------------------------------------- -----------------
``__cpp_lib_ranges`` ``202406L``
---------------------------------------------------------- -----------------
``__cpp_lib_ranges_as_const`` *unimplemented*
---------------------------------------------------------- -----------------
``__cpp_lib_ranges_as_rvalue`` ``202207L``
Expand Down
1 change: 1 addition & 0 deletions libcxx/docs/ReleaseNotes/20.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ What's New in Libc++ 20.0.0?
Implemented Papers
------------------

- P2609R3: Relaxing Ranges Just A Smidge (`Github <https://github.com/llvm/llvm-project/issues/105253>`__)
- P2985R0: A type trait for detecting virtual base classes (`Github <https://github.com/llvm/llvm-project/issues/105432>`__)


Expand Down
1 change: 1 addition & 0 deletions libcxx/docs/Status/Cxx23.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Paper Status
.. [#note-P2520R0] P2520R0: Libc++ implemented this paper as a DR in C++20 as well.
.. [#note-P2711R1] P2711R1: ``join_with_view`` hasn't been done yet since this type isn't implemented yet.
.. [#note-P2770R0] P2770R0: ``join_with_view`` hasn't been done yet since this type isn't implemented yet.
.. [#note-P2609R3] P2609R3: Libc++ implemented this paper as a DR in C++20 as well. (MSVC STL does the same.)
.. [#note-LWG3494] LWG3494: That LWG issue was superseded by `P2017R1 <https://wg21.link/P2017R1>`__.
.. [#note-LWG3481] LWG3481: That LWG issue was superseded by `P2415R2 <https://wg21.link/P2415R2>`__.
.. [#note-LWG3265] LWG3265: That LWG issue was resolved by `LWG3435 <https://wg21.link/LWG3435>`__.
Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx23Papers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"`P2770R0 <https://wg21.link/P2770R0>`__","Stashing stashing ``iterators`` for proper flattening","2023-02 (Issaquah)","|Partial| [#note-P2770R0]_","","|ranges|"
"`P2164R9 <https://wg21.link/P2164R9>`__","``views::enumerate``","2023-02 (Issaquah)","","","|ranges|"
"`P2711R1 <https://wg21.link/P2711R1>`__","Making multi-param constructors of ``views`` ``explicit``","2023-02 (Issaquah)","|In Progress| [#note-P2711R1]_","","|ranges|"
"`P2609R3 <https://wg21.link/P2609R3>`__","Relaxing Ranges Just A Smidge","2023-02 (Issaquah)","","","|ranges|"
"`P2609R3 <https://wg21.link/P2609R3>`__","Relaxing Ranges Just A Smidge","2023-02 (Issaquah)","|Complete| [#note-P2609R3]_","20.0","|ranges|"
"`P2713R1 <https://wg21.link/P2713R1>`__","Escaping improvements in ``std::format``","2023-02 (Issaquah)","|Complete|","19.0","|format|"
"`P2675R1 <https://wg21.link/P2675R1>`__","``format``'s width estimation is too approximate and not forward compatible","2023-02 (Issaquah)","|Complete|","17.0","|format|"
"`P2572R1 <https://wg21.link/P2572R1>`__","``std::format`` fill character allowances","2023-02 (Issaquah)","|Complete|","17.0","|format|"
Expand Down
58 changes: 43 additions & 15 deletions libcxx/include/__iterator/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <__type_traits/add_pointer.h>
#include <__type_traits/common_reference.h>
#include <__type_traits/is_pointer.h>
#include <__type_traits/is_primary_template.h>
#include <__type_traits/is_reference.h>
#include <__type_traits/remove_cv.h>
#include <__type_traits/remove_cvref.h>
Expand Down Expand Up @@ -64,8 +65,33 @@ concept __indirectly_readable_impl =
template <class _In>
concept indirectly_readable = __indirectly_readable_impl<remove_cvref_t<_In>>;

template <class _Tp>
using __projected_iterator_t = typename _Tp::__projected_iterator;

template <class _Tp>
using __projected_projection_t = typename _Tp::__projected_projection;

template <class _Tp>
concept __specialization_of_projected = requires {
typename __projected_iterator_t<_Tp>;
typename __projected_projection_t<_Tp>;
} && __is_primary_template<_Tp>::value;

template <class _Tp>
struct __indirect_value_t_impl {
using type = iter_value_t<_Tp>&;
};
template <__specialization_of_projected _Tp>
struct __indirect_value_t_impl<_Tp> {
using type = invoke_result_t<__projected_projection_t<_Tp>&,
typename __indirect_value_t_impl<__projected_iterator_t<_Tp>>::type>;
};

template <indirectly_readable _Tp>
using __indirect_value_t = typename __indirect_value_t_impl<_Tp>::type;

template <indirectly_readable _Tp>
using iter_common_reference_t = common_reference_t<iter_reference_t<_Tp>, iter_value_t<_Tp>&>;
using iter_common_reference_t = common_reference_t<iter_reference_t<_Tp>, __indirect_value_t<_Tp>>;

// [iterator.concept.writable]
template <class _Out, class _Tp>
Expand Down Expand Up @@ -176,43 +202,45 @@ concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip
// [indirectcallable.indirectinvocable]
template <class _Fp, class _It>
concept indirectly_unary_invocable =
indirectly_readable<_It> && copy_constructible<_Fp> && invocable<_Fp&, iter_value_t<_It>&> &&
indirectly_readable<_It> && copy_constructible<_Fp> && invocable<_Fp&, __indirect_value_t<_It>> &&
invocable<_Fp&, iter_reference_t<_It>> &&
common_reference_with< invoke_result_t<_Fp&, iter_value_t<_It>&>, invoke_result_t<_Fp&, iter_reference_t<_It>>>;
common_reference_with< invoke_result_t<_Fp&, __indirect_value_t<_It>>,
invoke_result_t<_Fp&, iter_reference_t<_It>>>;

template <class _Fp, class _It>
concept indirectly_regular_unary_invocable =
indirectly_readable<_It> && copy_constructible<_Fp> && regular_invocable<_Fp&, iter_value_t<_It>&> &&
indirectly_readable<_It> && copy_constructible<_Fp> && regular_invocable<_Fp&, __indirect_value_t<_It>> &&
regular_invocable<_Fp&, iter_reference_t<_It>> &&
common_reference_with< invoke_result_t<_Fp&, iter_value_t<_It>&>, invoke_result_t<_Fp&, iter_reference_t<_It>>>;
common_reference_with< invoke_result_t<_Fp&, __indirect_value_t<_It>>,
invoke_result_t<_Fp&, iter_reference_t<_It>>>;

template <class _Fp, class _It>
concept indirect_unary_predicate =
indirectly_readable<_It> && copy_constructible<_Fp> && predicate<_Fp&, iter_value_t<_It>&> &&
indirectly_readable<_It> && copy_constructible<_Fp> && predicate<_Fp&, __indirect_value_t<_It>> &&
predicate<_Fp&, iter_reference_t<_It>>;

template <class _Fp, class _It1, class _It2>
concept indirect_binary_predicate =
indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> &&
predicate<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> &&
predicate<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> &&
predicate<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> &&
predicate<_Fp&, __indirect_value_t<_It1>, __indirect_value_t<_It2>> &&
predicate<_Fp&, __indirect_value_t<_It1>, iter_reference_t<_It2>> &&
predicate<_Fp&, iter_reference_t<_It1>, __indirect_value_t<_It2>> &&
predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>;

template <class _Fp, class _It1, class _It2 = _It1>
concept indirect_equivalence_relation =
indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> &&
equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> &&
equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> &&
equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> &&
equivalence_relation<_Fp&, __indirect_value_t<_It1>, __indirect_value_t<_It2>> &&
equivalence_relation<_Fp&, __indirect_value_t<_It1>, iter_reference_t<_It2>> &&
equivalence_relation<_Fp&, iter_reference_t<_It1>, __indirect_value_t<_It2>> &&
equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>;

template <class _Fp, class _It1, class _It2 = _It1>
concept indirect_strict_weak_order =
indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> &&
strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> &&
strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> &&
strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> &&
strict_weak_order<_Fp&, __indirect_value_t<_It1>, __indirect_value_t<_It2>> &&
strict_weak_order<_Fp&, __indirect_value_t<_It1>, iter_reference_t<_It2>> &&
strict_weak_order<_Fp&, iter_reference_t<_It1>, __indirect_value_t<_It2>> &&
strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>;

template <class _Fp, class... _Its>
Expand Down
8 changes: 8 additions & 0 deletions libcxx/include/__iterator/projected.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _It, class _Proj>
struct __projected_impl {
struct __type {
using __primary_template = __type;
using __projected_iterator = _It;
using __projected_projection = _Proj;

using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>;
indirect_result_t<_Proj&, _It> operator*() const; // not defined
};
Expand All @@ -34,6 +38,10 @@ struct __projected_impl {
template <weakly_incrementable _It, class _Proj>
struct __projected_impl<_It, _Proj> {
struct __type {
using __primary_template = __type;
using __projected_iterator = _It;
using __projected_projection = _Proj;

using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>;
using difference_type = iter_difference_t<_It>;
indirect_result_t<_Proj&, _It> operator*() const; // not defined
Expand Down
Loading

0 comments on commit 0447d31

Please sign in to comment.