[libcxx-commits] [libcxx] 73d94b1 - [Libcxx] Add <source_location> header.
James Y Knight via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jan 11 13:02:40 PST 2023
Author: James Y Knight
Date: 2023-01-11T16:01:30-05:00
New Revision: 73d94b19161355d06f20678d628555719eebbdcc
URL: https://github.com/llvm/llvm-project/commit/73d94b19161355d06f20678d628555719eebbdcc
DIFF: https://github.com/llvm/llvm-project/commit/73d94b19161355d06f20678d628555719eebbdcc.diff
LOG: [Libcxx] Add <source_location> header.
This requires the __builtin_source_location() builtin, as implemented
by GCC and Clang.
Fixes https://github.com/llvm/llvm-project/issues/56363
Differential Revision: https://reviews.llvm.org/D120634
Added:
libcxx/include/source_location
libcxx/test/std/language.support/support.limits/support.limits.general/source_location.version.compile.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/source_location.version.pass.cpp
libcxx/test/std/language.support/support.srcloc/general.pass.cpp
Modified:
libcxx/docs/FeatureTestMacroTable.rst
libcxx/docs/ReleaseNotes.rst
libcxx/docs/Status/Cxx20Issues.csv
libcxx/docs/Status/Cxx20Papers.csv
libcxx/include/CMakeLists.txt
libcxx/include/module.modulemap.in
libcxx/include/version
libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp
libcxx/test/libcxx/clang_tidy.sh.cpp
libcxx/test/libcxx/double_include.sh.cpp
libcxx/test/libcxx/min_max_macros.compile.pass.cpp
libcxx/test/libcxx/modules_include.sh.cpp
libcxx/test/libcxx/nasty_macros.compile.pass.cpp
libcxx/test/libcxx/no_assert_include.compile.pass.cpp
libcxx/test/libcxx/transitive_includes.sh.cpp
libcxx/test/libcxx/transitive_includes/cxx03.csv
libcxx/test/libcxx/transitive_includes/cxx11.csv
libcxx/test/libcxx/transitive_includes/cxx14.csv
libcxx/test/libcxx/transitive_includes/cxx17.csv
libcxx/test/libcxx/transitive_includes/cxx20.csv
libcxx/test/libcxx/transitive_includes/cxx2b.csv
libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
libcxx/utils/generate_feature_test_macro_components.py
Removed:
################################################################################
diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst
index 34e28a31d9e12..a71e1e6963a72 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -274,7 +274,7 @@ Status
------------------------------------------------- -----------------
``__cpp_lib_smart_ptr_for_overwrite`` *unimplemented*
------------------------------------------------- -----------------
- ``__cpp_lib_source_location`` *unimplemented*
+ ``__cpp_lib_source_location`` ``201907L``
------------------------------------------------- -----------------
``__cpp_lib_span`` ``202002L``
------------------------------------------------- -----------------
diff --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index df0646e330157..bed5ee22bb3fe 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -51,6 +51,7 @@ Implemented Papers
- P0339R6 - ``polymorphic_allocator<>`` as a vocabulary type
- P1169R4 - ``static operator()``
- P0415R1 - ``constexpr`` for ``std::complex``
+- P1208R6 - ``std::source_location``
Improvements and New Features
-----------------------------
diff --git a/libcxx/docs/Status/Cxx20Issues.csv b/libcxx/docs/Status/Cxx20Issues.csv
index 2722e0bfe0b6d..d023df674c23b 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -295,7 +295,7 @@
"`3390 <https://wg21.link/LWG3390>`__","``make_move_iterator()``\ cannot be used to construct a ``move_iterator``\ for a move-only iterator","Prague","|Complete|","14.0","|ranges|"
"`3393 <https://wg21.link/LWG3393>`__","Missing/incorrect feature test macro for coroutines","Prague","|Complete|","14.0"
"`3395 <https://wg21.link/LWG3395>`__","Definition for three-way comparison needs to be updated (US 152)","Prague","","","|spaceship|"
-"`3396 <https://wg21.link/LWG3396>`__","Clarify point of reference for ``source_location::current()``\ (DE 169)","Prague","",""
+"`3396 <https://wg21.link/LWG3396>`__","Clarify point of reference for ``source_location::current()``\ (DE 169)","Prague","|Nothing To Do|","16.0"
"`3397 <https://wg21.link/LWG3397>`__","``ranges::basic_istream_view::iterator``\ should not provide ``iterator_category``\ ","Prague","|Complete|","16.0","|ranges|"
"`3398 <https://wg21.link/LWG3398>`__","``tuple_element_t``\ is also wrong for ``const subrange``\ ","Prague","|Complete|","14.0","|ranges|"
"`3446 <https://wg21.link/LWG3446>`__","``indirectly_readable_traits``\ ambiguity for types with both ``value_type``\ and ``element_type``\ ","November virtual meeting","|Complete|","13.0","|ranges|"
diff --git a/libcxx/docs/Status/Cxx20Papers.csv b/libcxx/docs/Status/Cxx20Papers.csv
index 43006ac9e5e84..b43c329bea355 100644
--- a/libcxx/docs/Status/Cxx20Papers.csv
+++ b/libcxx/docs/Status/Cxx20Papers.csv
@@ -112,7 +112,7 @@
"`P1065R2 <https://wg21.link/P1065R2>`__","LWG","Constexpr INVOKE","Cologne","|Complete|","12.0"
"`P1135R6 <https://wg21.link/P1135R6>`__","LWG","The C++20 Synchronization Library","Cologne","|Complete|","11.0"
"`P1207R4 <https://wg21.link/P1207R4>`__","LWG","Movability of Single-pass Iterators","Cologne","|Complete|","15.0","|ranges|"
-"`P1208R6 <https://wg21.link/P1208R6>`__","LWG","Adopt source_location for C++20","Cologne","",""
+"`P1208R6 <https://wg21.link/P1208R6>`__","LWG","Adopt source_location for C++20","Cologne","|Complete|","16.0"
"`P1355R2 <https://wg21.link/P1355R2>`__","LWG","Exposing a narrow contract for ceil2","Cologne","|Complete|","9.0"
"`P1361R2 <https://wg21.link/P1361R2>`__","LWG","Integration of chrono with text formatting","Cologne","|In Progress|",""
"`P1423R3 <https://wg21.link/P1423R3>`__","LWG","char8_t backward compatibility remediation","Cologne","|Complete|","15.0"
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 0a06f812aa8e5..7320bdf9acc05 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -824,6 +824,7 @@ set(files
set
setjmp.h
shared_mutex
+ source_location
span
sstream
stack
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 8706a46a244f4..73bd8a2b8e686 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1291,6 +1291,10 @@ module std [system] {
header "shared_mutex"
export version
}
+ module source_location {
+ header "source_location"
+ export *
+ }
module span {
header "span"
export ranges.__ranges.enable_borrowed_range
diff --git a/libcxx/include/source_location b/libcxx/include/source_location
new file mode 100644
index 0000000000000..4c4a09618ada9
--- /dev/null
+++ b/libcxx/include/source_location
@@ -0,0 +1,85 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SOURCE_LOCATION
+#define _LIBCPP_SOURCE_LOCATION
+
+/* source_location synopsis
+
+namespace std {
+ struct source_location {
+ static consteval source_location current() noexcept;
+ constexpr source_location() noexcept;
+
+ constexpr uint_least32_t line() const noexcept;
+ constexpr uint_least32_t column() const noexcept;
+ constexpr const char* file_name() const noexcept;
+ constexpr const char* function_name() const noexcept;
+ };
+}
+*/
+
+#include <__config>
+#include <cstdint>
+#include <version>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 20 && __has_builtin(__builtin_source_location)
+
+class source_location {
+ // The names source_location::__impl, _M_file_name, _M_function_name, _M_line, and _M_column
+ // are hard-coded in the compiler and must not be changed here.
+ struct __impl {
+ const char* _M_file_name;
+ const char* _M_function_name;
+ unsigned _M_line;
+ unsigned _M_column;
+ };
+ const __impl* __ptr_ = nullptr;
+ // GCC returns the type 'const void*' from the builtin, while clang returns
+ // `const __impl*`. Per C++ [expr.const], casts from void* are not permitted
+ // in constant evaluation, so we don't want to use `void*` as the argument
+ // type unless the builtin returned that, anyhow, and the invalid cast is
+ // unavoidable.
+ using __bsl_ty = decltype(__builtin_source_location());
+
+public:
+ // The defaulted __ptr argument is necessary so that the builtin is evaluated
+ // in the context of the caller. An explicit value should never be provided.
+ static consteval source_location current(__bsl_ty __ptr = __builtin_source_location()) noexcept {
+ source_location __sl;
+ __sl.__ptr_ = static_cast<const __impl*>(__ptr);
+ return __sl;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr source_location() noexcept = default;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr uint_least32_t line() const noexcept {
+ return __ptr_ != nullptr ? __ptr_->_M_line : 0;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr uint_least32_t column() const noexcept {
+ return __ptr_ != nullptr ? __ptr_->_M_column : 0;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr const char* file_name() const noexcept {
+ return __ptr_ != nullptr ? __ptr_->_M_file_name : "";
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr const char* function_name() const noexcept {
+ return __ptr_ != nullptr ? __ptr_->_M_function_name : "";
+ }
+};
+
+#endif // _LIBCPP_STD_VER >= 20 && __has_builtin(__builtin_source_location)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_SOURCE_LOCATION
diff --git a/libcxx/include/version b/libcxx/include/version
index d348325d1bf50..2b81418005b83 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -365,7 +365,9 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_shared_ptr_arrays 201707L
# define __cpp_lib_shift 201806L
// # define __cpp_lib_smart_ptr_for_overwrite 202002L
-// # define __cpp_lib_source_location 201907L
+# if __has_builtin(__builtin_source_location)
+# define __cpp_lib_source_location 201907L
+# endif
# define __cpp_lib_span 202002L
# define __cpp_lib_ssize 201902L
# define __cpp_lib_starts_ends_with 201711L
diff --git a/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp b/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp
index 690c792657c34..dcb5766377b08 100644
--- a/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp
+++ b/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp
@@ -524,252 +524,258 @@ int main(int, char**) { return 0; }
// RUN: %{build} -DTEST_89
#if defined(TEST_89)
-# include <span>
+# include <source_location>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_90
-#if defined(TEST_90) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <sstream>
+#if defined(TEST_90)
+# include <span>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_91
-#if defined(TEST_91)
+#if defined(TEST_91) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# include <sstream>
+ using HandlerType = decltype(std::__libcpp_verbose_abort);
+#endif
+
+// RUN: %{build} -DTEST_92
+#if defined(TEST_92)
# include <stack>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
-// RUN: %{build} -DTEST_95
-#if defined(TEST_95)
+// RUN: %{build} -DTEST_96
+#if defined(TEST_96)
# include <stdexcept>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
-// RUN: %{build} -DTEST_99
-#if defined(TEST_99) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+// RUN: %{build} -DTEST_100
+#if defined(TEST_100) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
# include <streambuf>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
-// RUN: %{build} -DTEST_100
-#if defined(TEST_100)
+// RUN: %{build} -DTEST_101
+#if defined(TEST_101)
# include <string>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
-// RUN: %{build} -DTEST_102
-#if defined(TEST_102)
+// RUN: %{build} -DTEST_103
+#if defined(TEST_103)
# include <string_view>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
-// RUN: %{build} -DTEST_103
-#if defined(TEST_103) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+// RUN: %{build} -DTEST_104
+#if defined(TEST_104) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
# include <strstream>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
-// RUN: %{build} -DTEST_104
-#if defined(TEST_104)
+// RUN: %{build} -DTEST_105
+#if defined(TEST_105)
# include <system_error>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
-// RUN: %{build} -DTEST_106
-#if defined(TEST_106) && !defined(_LIBCPP_HAS_NO_THREADS)
-# include <thread>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
// RUN: %{build} -DTEST_107
-#if defined(TEST_107)
-# include <tuple>
+#if defined(TEST_107) && !defined(_LIBCPP_HAS_NO_THREADS)
+# include <thread>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_108
#if defined(TEST_108)
-# include <type_traits>
+# include <tuple>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_109
#if defined(TEST_109)
-# include <typeindex>
+# include <type_traits>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_110
#if defined(TEST_110)
-# include <typeinfo>
+# include <typeindex>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
-// RUN: %{build} -DTEST_112
-#if defined(TEST_112)
-# include <unordered_map>
+// RUN: %{build} -DTEST_111
+#if defined(TEST_111)
+# include <typeinfo>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_113
#if defined(TEST_113)
-# include <unordered_set>
+# include <unordered_map>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_114
#if defined(TEST_114)
-# include <utility>
+# include <unordered_set>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_115
#if defined(TEST_115)
-# include <valarray>
+# include <utility>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_116
#if defined(TEST_116)
-# include <variant>
+# include <valarray>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_117
#if defined(TEST_117)
-# include <vector>
+# include <variant>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_118
#if defined(TEST_118)
-# include <version>
+# include <vector>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
-// RUN: %{build} -DTEST_121
-#if defined(TEST_121) && __cplusplus >= 201103L
-# include <experimental/algorithm>
+// RUN: %{build} -DTEST_119
+#if defined(TEST_119)
+# include <version>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_122
-#if defined(TEST_122) && __cplusplus >= 201103L && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES)
-# include <experimental/coroutine>
+#if defined(TEST_122) && __cplusplus >= 201103L
+# include <experimental/algorithm>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_123
-#if defined(TEST_123) && __cplusplus >= 201103L
-# include <experimental/deque>
+#if defined(TEST_123) && __cplusplus >= 201103L && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES)
+# include <experimental/coroutine>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_124
#if defined(TEST_124) && __cplusplus >= 201103L
-# include <experimental/forward_list>
+# include <experimental/deque>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_125
#if defined(TEST_125) && __cplusplus >= 201103L
-# include <experimental/functional>
+# include <experimental/forward_list>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_126
#if defined(TEST_126) && __cplusplus >= 201103L
-# include <experimental/iterator>
+# include <experimental/functional>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_127
#if defined(TEST_127) && __cplusplus >= 201103L
-# include <experimental/list>
+# include <experimental/iterator>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_128
#if defined(TEST_128) && __cplusplus >= 201103L
-# include <experimental/map>
+# include <experimental/list>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_129
#if defined(TEST_129) && __cplusplus >= 201103L
-# include <experimental/memory_resource>
+# include <experimental/map>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_130
#if defined(TEST_130) && __cplusplus >= 201103L
-# include <experimental/propagate_const>
+# include <experimental/memory_resource>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_131
-#if defined(TEST_131) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L
-# include <experimental/regex>
+#if defined(TEST_131) && __cplusplus >= 201103L
+# include <experimental/propagate_const>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_132
-#if defined(TEST_132) && __cplusplus >= 201103L
-# include <experimental/set>
+#if defined(TEST_132) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L
+# include <experimental/regex>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_133
#if defined(TEST_133) && __cplusplus >= 201103L
-# include <experimental/simd>
+# include <experimental/set>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_134
#if defined(TEST_134) && __cplusplus >= 201103L
-# include <experimental/string>
+# include <experimental/simd>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_135
#if defined(TEST_135) && __cplusplus >= 201103L
-# include <experimental/type_traits>
+# include <experimental/string>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_136
#if defined(TEST_136) && __cplusplus >= 201103L
-# include <experimental/unordered_map>
+# include <experimental/type_traits>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_137
#if defined(TEST_137) && __cplusplus >= 201103L
-# include <experimental/unordered_set>
+# include <experimental/unordered_map>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_138
#if defined(TEST_138) && __cplusplus >= 201103L
-# include <experimental/utility>
+# include <experimental/unordered_set>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_139
#if defined(TEST_139) && __cplusplus >= 201103L
-# include <experimental/vector>
+# include <experimental/utility>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_140
-#if defined(TEST_140)
-# include <ext/hash_map>
+#if defined(TEST_140) && __cplusplus >= 201103L
+# include <experimental/vector>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
// RUN: %{build} -DTEST_141
#if defined(TEST_141)
+# include <ext/hash_map>
+ using HandlerType = decltype(std::__libcpp_verbose_abort);
+#endif
+
+// RUN: %{build} -DTEST_142
+#if defined(TEST_142)
# include <ext/hash_set>
using HandlerType = decltype(std::__libcpp_verbose_abort);
#endif
diff --git a/libcxx/test/libcxx/clang_tidy.sh.cpp b/libcxx/test/libcxx/clang_tidy.sh.cpp
index 7e4b88b91114b..cef418169a9c7 100644
--- a/libcxx/test/libcxx/clang_tidy.sh.cpp
+++ b/libcxx/test/libcxx/clang_tidy.sh.cpp
@@ -165,6 +165,7 @@ END-SCRIPT
#if !defined(_LIBCPP_HAS_NO_THREADS)
# include <shared_mutex>
#endif
+#include <source_location>
#include <span>
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
# include <sstream>
diff --git a/libcxx/test/libcxx/double_include.sh.cpp b/libcxx/test/libcxx/double_include.sh.cpp
index 0bb3c9c0e5c0a..afe9ca60c8af3 100644
--- a/libcxx/test/libcxx/double_include.sh.cpp
+++ b/libcxx/test/libcxx/double_include.sh.cpp
@@ -166,6 +166,7 @@ END-SCRIPT
#if !defined(_LIBCPP_HAS_NO_THREADS)
# include <shared_mutex>
#endif
+#include <source_location>
#include <span>
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
# include <sstream>
diff --git a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp
index f9a151dae5ddb..e2098ac03c04e 100644
--- a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp
+++ b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp
@@ -255,6 +255,8 @@ TEST_MACROS();
# include <shared_mutex>
TEST_MACROS();
#endif
+#include <source_location>
+TEST_MACROS();
#include <span>
TEST_MACROS();
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
diff --git a/libcxx/test/libcxx/modules_include.sh.cpp b/libcxx/test/libcxx/modules_include.sh.cpp
index dfec3792e25df..dc0bef2118431 100644
--- a/libcxx/test/libcxx/modules_include.sh.cpp
+++ b/libcxx/test/libcxx/modules_include.sh.cpp
@@ -407,214 +407,218 @@ END-SCRIPT
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_89
#if defined(TEST_89)
-#include <span>
+#include <source_location>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_90
-#if defined(TEST_90) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#include <sstream>
+#if defined(TEST_90)
+#include <span>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_91
-#if defined(TEST_91)
-#include <stack>
+#if defined(TEST_91) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#include <sstream>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_92
-#if defined(TEST_92) && __cplusplus > 202002L && !defined(_LIBCPP_HAS_NO_THREADS)
-#include <stdatomic.h>
+#if defined(TEST_92)
+#include <stack>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_93
-#if defined(TEST_93)
-#include <stdbool.h>
+#if defined(TEST_93) && __cplusplus > 202002L && !defined(_LIBCPP_HAS_NO_THREADS)
+#include <stdatomic.h>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_94
#if defined(TEST_94)
-#include <stddef.h>
+#include <stdbool.h>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_95
#if defined(TEST_95)
-#include <stdexcept>
+#include <stddef.h>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_96
#if defined(TEST_96)
-#include <stdint.h>
+#include <stdexcept>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_97
#if defined(TEST_97)
-#include <stdio.h>
+#include <stdint.h>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_98
#if defined(TEST_98)
-#include <stdlib.h>
+#include <stdio.h>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_99
-#if defined(TEST_99) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#include <streambuf>
+#if defined(TEST_99)
+#include <stdlib.h>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_100
-#if defined(TEST_100)
-#include <string>
+#if defined(TEST_100) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#include <streambuf>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_101
#if defined(TEST_101)
-#include <string.h>
+#include <string>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_102
#if defined(TEST_102)
-#include <string_view>
+#include <string.h>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_103
-#if defined(TEST_103) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#include <strstream>
+#if defined(TEST_103)
+#include <string_view>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_104
-#if defined(TEST_104)
-#include <system_error>
+#if defined(TEST_104) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#include <strstream>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_105
#if defined(TEST_105)
-#include <tgmath.h>
+#include <system_error>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_106
-#if defined(TEST_106) && !defined(_LIBCPP_HAS_NO_THREADS)
-#include <thread>
+#if defined(TEST_106)
+#include <tgmath.h>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_107
-#if defined(TEST_107)
-#include <tuple>
+#if defined(TEST_107) && !defined(_LIBCPP_HAS_NO_THREADS)
+#include <thread>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_108
#if defined(TEST_108)
-#include <type_traits>
+#include <tuple>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_109
#if defined(TEST_109)
-#include <typeindex>
+#include <type_traits>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_110
#if defined(TEST_110)
-#include <typeinfo>
+#include <typeindex>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_111
#if defined(TEST_111)
-#include <uchar.h>
+#include <typeinfo>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_112
#if defined(TEST_112)
-#include <unordered_map>
+#include <uchar.h>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_113
#if defined(TEST_113)
-#include <unordered_set>
+#include <unordered_map>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_114
#if defined(TEST_114)
-#include <utility>
+#include <unordered_set>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_115
#if defined(TEST_115)
-#include <valarray>
+#include <utility>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_116
#if defined(TEST_116)
-#include <variant>
+#include <valarray>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_117
#if defined(TEST_117)
-#include <vector>
+#include <variant>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_118
#if defined(TEST_118)
-#include <version>
+#include <vector>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_119
-#if defined(TEST_119) && !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
-#include <wchar.h>
+#if defined(TEST_119)
+#include <version>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_120
#if defined(TEST_120) && !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
-#include <wctype.h>
+#include <wchar.h>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_121
-#if defined(TEST_121) && __cplusplus >= 201103L
-#include <experimental/algorithm>
+#if defined(TEST_121) && !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#include <wctype.h>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_122
-#if defined(TEST_122) && __cplusplus >= 201103L && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES)
-#include <experimental/coroutine>
+#if defined(TEST_122) && __cplusplus >= 201103L
+#include <experimental/algorithm>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_123
-#if defined(TEST_123) && __cplusplus >= 201103L
-#include <experimental/deque>
+#if defined(TEST_123) && __cplusplus >= 201103L && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES)
+#include <experimental/coroutine>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_124
#if defined(TEST_124) && __cplusplus >= 201103L
-#include <experimental/forward_list>
+#include <experimental/deque>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_125
#if defined(TEST_125) && __cplusplus >= 201103L
-#include <experimental/functional>
+#include <experimental/forward_list>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_126
#if defined(TEST_126) && __cplusplus >= 201103L
-#include <experimental/iterator>
+#include <experimental/functional>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_127
#if defined(TEST_127) && __cplusplus >= 201103L
-#include <experimental/list>
+#include <experimental/iterator>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_128
#if defined(TEST_128) && __cplusplus >= 201103L
-#include <experimental/map>
+#include <experimental/list>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_129
#if defined(TEST_129) && __cplusplus >= 201103L
-#include <experimental/memory_resource>
+#include <experimental/map>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_130
#if defined(TEST_130) && __cplusplus >= 201103L
-#include <experimental/propagate_const>
+#include <experimental/memory_resource>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_131
-#if defined(TEST_131) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L
-#include <experimental/regex>
+#if defined(TEST_131) && __cplusplus >= 201103L
+#include <experimental/propagate_const>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_132
-#if defined(TEST_132) && __cplusplus >= 201103L
-#include <experimental/set>
+#if defined(TEST_132) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L
+#include <experimental/regex>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_133
#if defined(TEST_133) && __cplusplus >= 201103L
-#include <experimental/simd>
+#include <experimental/set>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_134
#if defined(TEST_134) && __cplusplus >= 201103L
-#include <experimental/string>
+#include <experimental/simd>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_135
#if defined(TEST_135) && __cplusplus >= 201103L
-#include <experimental/type_traits>
+#include <experimental/string>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_136
#if defined(TEST_136) && __cplusplus >= 201103L
-#include <experimental/unordered_map>
+#include <experimental/type_traits>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_137
#if defined(TEST_137) && __cplusplus >= 201103L
-#include <experimental/unordered_set>
+#include <experimental/unordered_map>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_138
#if defined(TEST_138) && __cplusplus >= 201103L
-#include <experimental/utility>
+#include <experimental/unordered_set>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_139
#if defined(TEST_139) && __cplusplus >= 201103L
-#include <experimental/vector>
+#include <experimental/utility>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_140
-#if defined(TEST_140)
-#include <ext/hash_map>
+#if defined(TEST_140) && __cplusplus >= 201103L
+#include <experimental/vector>
#endif
// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_141
#if defined(TEST_141)
+#include <ext/hash_map>
+#endif
+// RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_142
+#if defined(TEST_142)
#include <ext/hash_set>
#endif
// GENERATED-MARKER
diff --git a/libcxx/test/libcxx/nasty_macros.compile.pass.cpp b/libcxx/test/libcxx/nasty_macros.compile.pass.cpp
index 93c54a4b74c82..30ad9a4ed85c1 100644
--- a/libcxx/test/libcxx/nasty_macros.compile.pass.cpp
+++ b/libcxx/test/libcxx/nasty_macros.compile.pass.cpp
@@ -290,6 +290,7 @@ END-SCRIPT
#if !defined(_LIBCPP_HAS_NO_THREADS)
# include <shared_mutex>
#endif
+#include <source_location>
#include <span>
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
# include <sstream>
diff --git a/libcxx/test/libcxx/no_assert_include.compile.pass.cpp b/libcxx/test/libcxx/no_assert_include.compile.pass.cpp
index 32bd4e66f8183..189f48fa2e4a8 100644
--- a/libcxx/test/libcxx/no_assert_include.compile.pass.cpp
+++ b/libcxx/test/libcxx/no_assert_include.compile.pass.cpp
@@ -163,6 +163,7 @@ END-SCRIPT
#if !defined(_LIBCPP_HAS_NO_THREADS)
# include <shared_mutex>
#endif
+#include <source_location>
#include <span>
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
# include <sstream>
diff --git a/libcxx/test/libcxx/transitive_includes.sh.cpp b/libcxx/test/libcxx/transitive_includes.sh.cpp
index 341debc713b2f..5eaca9788aa81 100644
--- a/libcxx/test/libcxx/transitive_includes.sh.cpp
+++ b/libcxx/test/libcxx/transitive_includes.sh.cpp
@@ -393,172 +393,176 @@ END-SCRIPT
#if defined(TEST_88)
#include <shared_mutex>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_89 2> %t/header.span
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_89 2> %t/header.source_location
#if defined(TEST_89)
-#include <span>
+#include <source_location>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_90 2> %t/header.sstream
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_90 2> %t/header.span
#if defined(TEST_90)
-#include <sstream>
+#include <span>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_91 2> %t/header.stack
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_91 2> %t/header.sstream
#if defined(TEST_91)
+#include <sstream>
+#endif
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_92 2> %t/header.stack
+#if defined(TEST_92)
#include <stack>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_95 2> %t/header.stdexcept
-#if defined(TEST_95)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_96 2> %t/header.stdexcept
+#if defined(TEST_96)
#include <stdexcept>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_99 2> %t/header.streambuf
-#if defined(TEST_99)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_100 2> %t/header.streambuf
+#if defined(TEST_100)
#include <streambuf>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_100 2> %t/header.string
-#if defined(TEST_100)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_101 2> %t/header.string
+#if defined(TEST_101)
#include <string>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_102 2> %t/header.string_view
-#if defined(TEST_102)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_103 2> %t/header.string_view
+#if defined(TEST_103)
#include <string_view>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_103 2> %t/header.strstream
-#if defined(TEST_103)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_104 2> %t/header.strstream
+#if defined(TEST_104)
#include <strstream>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_104 2> %t/header.system_error
-#if defined(TEST_104)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_105 2> %t/header.system_error
+#if defined(TEST_105)
#include <system_error>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_106 2> %t/header.thread
-#if defined(TEST_106)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_107 2> %t/header.thread
+#if defined(TEST_107)
#include <thread>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_107 2> %t/header.tuple
-#if defined(TEST_107)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_108 2> %t/header.tuple
+#if defined(TEST_108)
#include <tuple>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_108 2> %t/header.type_traits
-#if defined(TEST_108)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_109 2> %t/header.type_traits
+#if defined(TEST_109)
#include <type_traits>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_109 2> %t/header.typeindex
-#if defined(TEST_109)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_110 2> %t/header.typeindex
+#if defined(TEST_110)
#include <typeindex>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_110 2> %t/header.typeinfo
-#if defined(TEST_110)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_111 2> %t/header.typeinfo
+#if defined(TEST_111)
#include <typeinfo>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_112 2> %t/header.unordered_map
-#if defined(TEST_112)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_113 2> %t/header.unordered_map
+#if defined(TEST_113)
#include <unordered_map>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_113 2> %t/header.unordered_set
-#if defined(TEST_113)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_114 2> %t/header.unordered_set
+#if defined(TEST_114)
#include <unordered_set>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_114 2> %t/header.utility
-#if defined(TEST_114)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_115 2> %t/header.utility
+#if defined(TEST_115)
#include <utility>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_115 2> %t/header.valarray
-#if defined(TEST_115)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_116 2> %t/header.valarray
+#if defined(TEST_116)
#include <valarray>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_116 2> %t/header.variant
-#if defined(TEST_116)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_117 2> %t/header.variant
+#if defined(TEST_117)
#include <variant>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_117 2> %t/header.vector
-#if defined(TEST_117)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_118 2> %t/header.vector
+#if defined(TEST_118)
#include <vector>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_118 2> %t/header.version
-#if defined(TEST_118)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_119 2> %t/header.version
+#if defined(TEST_119)
#include <version>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_121 2> %t/header.experimental_algorithm
-#if defined(TEST_121)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_122 2> %t/header.experimental_algorithm
+#if defined(TEST_122)
#include <experimental/algorithm>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_122 2> %t/header.experimental_coroutine
-#if defined(TEST_122)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_123 2> %t/header.experimental_coroutine
+#if defined(TEST_123)
#include <experimental/coroutine>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_123 2> %t/header.experimental_deque
-#if defined(TEST_123)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_124 2> %t/header.experimental_deque
+#if defined(TEST_124)
#include <experimental/deque>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_124 2> %t/header.experimental_forward_list
-#if defined(TEST_124)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_125 2> %t/header.experimental_forward_list
+#if defined(TEST_125)
#include <experimental/forward_list>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_125 2> %t/header.experimental_functional
-#if defined(TEST_125)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_126 2> %t/header.experimental_functional
+#if defined(TEST_126)
#include <experimental/functional>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_126 2> %t/header.experimental_iterator
-#if defined(TEST_126)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_127 2> %t/header.experimental_iterator
+#if defined(TEST_127)
#include <experimental/iterator>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_127 2> %t/header.experimental_list
-#if defined(TEST_127)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_128 2> %t/header.experimental_list
+#if defined(TEST_128)
#include <experimental/list>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_128 2> %t/header.experimental_map
-#if defined(TEST_128)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_129 2> %t/header.experimental_map
+#if defined(TEST_129)
#include <experimental/map>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_129 2> %t/header.experimental_memory_resource
-#if defined(TEST_129)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_130 2> %t/header.experimental_memory_resource
+#if defined(TEST_130)
#include <experimental/memory_resource>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_130 2> %t/header.experimental_propagate_const
-#if defined(TEST_130)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_131 2> %t/header.experimental_propagate_const
+#if defined(TEST_131)
#include <experimental/propagate_const>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_131 2> %t/header.experimental_regex
-#if defined(TEST_131)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_132 2> %t/header.experimental_regex
+#if defined(TEST_132)
#include <experimental/regex>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_132 2> %t/header.experimental_set
-#if defined(TEST_132)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_133 2> %t/header.experimental_set
+#if defined(TEST_133)
#include <experimental/set>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_133 2> %t/header.experimental_simd
-#if defined(TEST_133)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_134 2> %t/header.experimental_simd
+#if defined(TEST_134)
#include <experimental/simd>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_134 2> %t/header.experimental_string
-#if defined(TEST_134)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_135 2> %t/header.experimental_string
+#if defined(TEST_135)
#include <experimental/string>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_135 2> %t/header.experimental_type_traits
-#if defined(TEST_135)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_136 2> %t/header.experimental_type_traits
+#if defined(TEST_136)
#include <experimental/type_traits>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_136 2> %t/header.experimental_unordered_map
-#if defined(TEST_136)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_137 2> %t/header.experimental_unordered_map
+#if defined(TEST_137)
#include <experimental/unordered_map>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_137 2> %t/header.experimental_unordered_set
-#if defined(TEST_137)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_138 2> %t/header.experimental_unordered_set
+#if defined(TEST_138)
#include <experimental/unordered_set>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_138 2> %t/header.experimental_utility
-#if defined(TEST_138)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_139 2> %t/header.experimental_utility
+#if defined(TEST_139)
#include <experimental/utility>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_139 2> %t/header.experimental_vector
-#if defined(TEST_139)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_140 2> %t/header.experimental_vector
+#if defined(TEST_140)
#include <experimental/vector>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_140 2> %t/header.ext_hash_map
-#if defined(TEST_140)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_141 2> %t/header.ext_hash_map
+#if defined(TEST_141)
#include <ext/hash_map>
#endif
-// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_141 2> %t/header.ext_hash_set
-#if defined(TEST_141)
+// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes -fsyntax-only -DTEST_142 2> %t/header.ext_hash_set
+#if defined(TEST_142)
#include <ext/hash_set>
#endif
// RUN: %{python} %S/transitive_includes_to_csv.py %t > %t/transitive_includes.csv
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index b5c1e9831e4aa..b67b167a4f0aa 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -743,6 +743,8 @@ set tuple
set type_traits
set version
shared_mutex version
+source_location cstdint
+source_location version
span array
span concepts
span cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index 6880ba7aeac61..ebe07a4046791 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -744,6 +744,8 @@ set tuple
set type_traits
set version
shared_mutex version
+source_location cstdint
+source_location version
span array
span concepts
span cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index c6de5a8e10d2d..dbbf4f75e9f44 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -752,6 +752,8 @@ shared_mutex ratio
shared_mutex system_error
shared_mutex type_traits
shared_mutex version
+source_location cstdint
+source_location version
span array
span concepts
span cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index c6de5a8e10d2d..dbbf4f75e9f44 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -752,6 +752,8 @@ shared_mutex ratio
shared_mutex system_error
shared_mutex type_traits
shared_mutex version
+source_location cstdint
+source_location version
span array
span concepts
span cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index c1aeb504bd0a9..410fced1635d6 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -759,6 +759,8 @@ shared_mutex ratio
shared_mutex system_error
shared_mutex type_traits
shared_mutex version
+source_location cstdint
+source_location version
span array
span concepts
span cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx2b.csv b/libcxx/test/libcxx/transitive_includes/cxx2b.csv
index 0e6f3780b8675..02af75aca7c6e 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx2b.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx2b.csv
@@ -569,6 +569,8 @@ shared_mutex ratio
shared_mutex system_error
shared_mutex type_traits
shared_mutex version
+source_location cstdint
+source_location version
span array
span cstddef
span initializer_list
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/source_location.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/source_location.version.compile.pass.cpp
new file mode 100644
index 0000000000000..0b3bad53766d7
--- /dev/null
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/source_location.version.compile.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// WARNING: This test was generated by generate_feature_test_macro_components.py
+// and should not be edited manually.
+//
+// clang-format off
+
+// <source_location>
+
+// Test the feature test macros defined by <source_location>
+
+/* Constant Value
+ __cpp_lib_source_location 201907L [C++20]
+*/
+
+#include <source_location>
+#include "test_macros.h"
+
+#if TEST_STD_VER < 14
+
+# ifdef __cpp_lib_source_location
+# error "__cpp_lib_source_location should not be defined before c++20"
+# endif
+
+#elif TEST_STD_VER == 14
+
+# ifdef __cpp_lib_source_location
+# error "__cpp_lib_source_location should not be defined before c++20"
+# endif
+
+#elif TEST_STD_VER == 17
+
+# ifdef __cpp_lib_source_location
+# error "__cpp_lib_source_location should not be defined before c++20"
+# endif
+
+#elif TEST_STD_VER == 20
+
+# if __has_builtin(__builtin_source_location)
+# ifndef __cpp_lib_source_location
+# error "__cpp_lib_source_location should be defined in c++20"
+# endif
+# if __cpp_lib_source_location != 201907L
+# error "__cpp_lib_source_location should have the value 201907L in c++20"
+# endif
+# else
+# ifdef __cpp_lib_source_location
+# error "__cpp_lib_source_location should not be defined when the requirement '__has_builtin(__builtin_source_location)' is not met!"
+# endif
+# endif
+
+#elif TEST_STD_VER > 20
+
+# if __has_builtin(__builtin_source_location)
+# ifndef __cpp_lib_source_location
+# error "__cpp_lib_source_location should be defined in c++2b"
+# endif
+# if __cpp_lib_source_location != 201907L
+# error "__cpp_lib_source_location should have the value 201907L in c++2b"
+# endif
+# else
+# ifdef __cpp_lib_source_location
+# error "__cpp_lib_source_location should not be defined when the requirement '__has_builtin(__builtin_source_location)' is not met!"
+# endif
+# endif
+
+#endif // TEST_STD_VER > 20
+
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/source_location.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/source_location.version.pass.cpp
new file mode 100644
index 0000000000000..c3ed9831ecff9
--- /dev/null
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/source_location.version.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// WARNING: This test was generated by generate_feature_test_macro_components.py
+// and should not be edited manually.
+//
+// clang-format off
+
+// <source_location>
+
+// Test the feature test macros defined by <source_location>
+
+/* Constant Value
+ __cpp_lib_source_location 201907L [C++20]
+*/
+
+#include <source_location>
+#include "test_macros.h"
+
+#if TEST_STD_VER < 14
+
+# ifdef __cpp_lib_source_location
+# error "__cpp_lib_source_location should not be defined before c++20"
+# endif
+
+#elif TEST_STD_VER == 14
+
+# ifdef __cpp_lib_source_location
+# error "__cpp_lib_source_location should not be defined before c++20"
+# endif
+
+#elif TEST_STD_VER == 17
+
+# ifdef __cpp_lib_source_location
+# error "__cpp_lib_source_location should not be defined before c++20"
+# endif
+
+#elif TEST_STD_VER == 20
+
+# if __has_builtin(__builtin_source_location)
+# ifndef __cpp_lib_source_location
+# error "__cpp_lib_source_location should be defined in c++20"
+# endif
+# if __cpp_lib_source_location != 201907L
+# error "__cpp_lib_source_location should have the value 201907L in c++20"
+# endif
+# else
+# ifdef __cpp_lib_source_location
+# error "__cpp_lib_source_location should not be defined when __has_builtin(__builtin_source_location) is not defined!"
+# endif
+# endif
+
+#elif TEST_STD_VER > 20
+
+# if __has_builtin(__builtin_source_location)
+# ifndef __cpp_lib_source_location
+# error "__cpp_lib_source_location should be defined in c++2b"
+# endif
+# if __cpp_lib_source_location != 201907L
+# error "__cpp_lib_source_location should have the value 201907L in c++2b"
+# endif
+# else
+# ifdef __cpp_lib_source_location
+# error "__cpp_lib_source_location should not be defined when __has_builtin(__builtin_source_location) is not defined!"
+# endif
+# endif
+
+#endif // TEST_STD_VER > 20
+
+int main(int, char**) { return 0; }
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
index 9af0226b0e5e4..7e1dfd066c4ff 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
@@ -3391,16 +3391,16 @@
# endif
# endif
-# if !defined(_LIBCPP_VERSION)
+# if __has_builtin(__builtin_source_location)
# ifndef __cpp_lib_source_location
# error "__cpp_lib_source_location should be defined in c++20"
# endif
# if __cpp_lib_source_location != 201907L
# error "__cpp_lib_source_location should have the value 201907L in c++20"
# endif
-# else // _LIBCPP_VERSION
+# else
# ifdef __cpp_lib_source_location
-# error "__cpp_lib_source_location should not be defined because it is unimplemented in libc++!"
+# error "__cpp_lib_source_location should not be defined when the requirement '__has_builtin(__builtin_source_location)' is not met!"
# endif
# endif
@@ -4737,16 +4737,16 @@
# endif
# endif
-# if !defined(_LIBCPP_VERSION)
+# if __has_builtin(__builtin_source_location)
# ifndef __cpp_lib_source_location
# error "__cpp_lib_source_location should be defined in c++2b"
# endif
# if __cpp_lib_source_location != 201907L
# error "__cpp_lib_source_location should have the value 201907L in c++2b"
# endif
-# else // _LIBCPP_VERSION
+# else
# ifdef __cpp_lib_source_location
-# error "__cpp_lib_source_location should not be defined because it is unimplemented in libc++!"
+# error "__cpp_lib_source_location should not be defined when the requirement '__has_builtin(__builtin_source_location)' is not met!"
# endif
# endif
diff --git a/libcxx/test/std/language.support/support.srcloc/general.pass.cpp b/libcxx/test/std/language.support/support.srcloc/general.pass.cpp
new file mode 100644
index 0000000000000..39ad936628ee3
--- /dev/null
+++ b/libcxx/test/std/language.support/support.srcloc/general.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-14, clang-15
+// UNSUPPORTED: apple-clang-14
+
+#include <source_location>
+
+#include <cassert>
+#include <concepts>
+#include <cstdint>
+#include <cstring>
+#include <type_traits>
+
+#include "test_macros.h"
+
+static_assert(std::is_nothrow_move_constructible_v<std::source_location>, "support.srcloc.cons (1.1)");
+static_assert(std::is_nothrow_move_assignable_v<std::source_location>, "support.srcloc.cons (1.2)");
+static_assert(std::is_nothrow_swappable_v<std::source_location>, "support.srcloc.cons (1.3)");
+
+ASSERT_NOEXCEPT(std::source_location());
+ASSERT_NOEXCEPT(std::source_location::current());
+
+// Note: the standard doesn't strictly require the particular values asserted
+// here, but does "suggest" them. Additional tests for details of how the
+// implementation of current() chooses which location to report for more complex
+// scenarios are in the Clang test-suite, and not replicated here.
+
+// A default-constructed value.
+constexpr std::source_location empty;
+static_assert(empty.line() == 0);
+static_assert(empty.column() == 0);
+static_assert(empty.file_name()[0] == '\0');
+static_assert(empty.function_name()[0] == '\0');
+
+ASSERT_NOEXCEPT(empty.line());
+ASSERT_NOEXCEPT(empty.column());
+ASSERT_NOEXCEPT(empty.file_name());
+ASSERT_NOEXCEPT(empty.function_name());
+std::same_as<uint_least32_t> auto line = empty.line();
+std::same_as<uint_least32_t> auto column = empty.column();
+std::same_as<const char*> auto file = empty.file_name();
+std::same_as<const char*> auto function = empty.function_name();
+
+// A simple use of current() outside a function.
+constexpr std::source_location cur =
+#line 1000 "ss"
+ std::source_location::current();
+static_assert(cur.line() == 1000);
+static_assert(cur.column() > 0);
+static_assert(cur.file_name()[0] == 's' && cur.file_name()[1] == 's' && cur.file_name()[2] == '\0');
+static_assert(cur.function_name()[0] == '\0');
+
+// and inside a function.
+int main(int, char**) {
+ auto local =
+#line 2000
+ std::source_location::current();
+ assert(strcmp(local.file_name(), "ss") == 0);
+ assert(strstr(local.function_name(), "main") != nullptr);
+ assert(local.line() == 2000);
+ assert(local.column() > 0);
+
+ // Finally, the type should be copy-constructible
+ auto local2 = cur;
+ assert(strcmp(local2.file_name(), cur.file_name()) == 0);
+ assert(strcmp(local2.function_name(), cur.function_name()) == 0);
+ assert(local2.line() == cur.line());
+ assert(local2.column() == cur.column());
+
+ // and copy-assignable.
+ local = cur;
+ assert(strcmp(local.file_name(), cur.file_name()) == 0);
+ assert(strcmp(local.function_name(), cur.function_name()) == 0);
+ assert(local.line() == cur.line());
+ assert(local.column() == cur.column());
+
+ return 0;
+}
diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index c09ea3e980b89..05a02b0150c68 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -644,7 +644,8 @@ def add_version_header(tc):
"name": "__cpp_lib_source_location",
"values": { "c++20": 201907 },
"headers": ["source_location"],
- "unimplemented": True,
+ "test_suite_guard": "__has_builtin(__builtin_source_location)",
+ "libcxx_guard": "__has_builtin(__builtin_source_location)",
}, {
"name": "__cpp_lib_span",
"values": { "c++20": 202002 },
More information about the libcxx-commits
mailing list