Skip to content

Commit

Permalink
Implement the infrastructure for feature-test macros. Very few actual…
Browse files Browse the repository at this point in the history
… feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955

llvm-svn: 342073
  • Loading branch information
mclow committed Sep 12, 2018
1 parent 956ff0f commit f56972e
Show file tree
Hide file tree
Showing 77 changed files with 1,535 additions and 11 deletions.
1 change: 1 addition & 0 deletions libcxx/include/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ template <class BidirectionalIterator, class Compare>
#include <iterator>
#include <cstddef>
#include <bit>
#include <version>

#include <__debug>

Expand Down
1 change: 1 addition & 0 deletions libcxx/include/any
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ namespace std {
#include <typeinfo>
#include <type_traits>
#include <cstdlib>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/array
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
#include <algorithm>
#include <stdexcept>
#include <cstdlib> // for _LIBCPP_UNREACHABLE
#include <version>
#include <__debug>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down
5 changes: 1 addition & 4 deletions libcxx/include/atomic
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ void atomic_signal_fence(memory_order m) noexcept;
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand All @@ -559,10 +560,6 @@ void atomic_signal_fence(memory_order m) noexcept;
#error C++ standard library is incompatible with <stdatomic.h>
#endif

#if _LIBCPP_STD_VER > 14
# define __cpp_lib_atomic_is_always_lock_free 201603L
#endif

#define _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) \
_LIBCPP_DIAGNOSE_WARNING(__m == memory_order_consume || \
__m == memory_order_acquire || \
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/bit
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace std {
*/

#include <__config>
#include <version>

#if defined(__IBMCPP__)
#include "support/ibm/support.h"
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ constexpr chrono::year operator ""y(unsigned lo
#include <type_traits>
#include <ratio>
#include <limits>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/cmath
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ long double truncl(long double x);

#include <__config>
#include <math.h>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/complex
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ template<class T, class charT, class traits>
#include <stdexcept>
#include <cmath>
#include <sstream>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/cstddef
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Types:
*/

#include <__config>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/deque
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ template <class T, class Allocator>
#include <iterator>
#include <algorithm>
#include <stdexcept>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/exception
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ template <class E> void rethrow_if_nested(const E& e);
#include <cstddef>
#include <cstdlib>
#include <type_traits>
#include <version>

#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
#include <vcruntime_exception.h>
Expand Down
5 changes: 1 addition & 4 deletions libcxx/include/filesystem
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
#include <utility>
#include <iomanip> // for quoted
#include <string_view>
#include <version>

#include <__debug>

Expand All @@ -256,10 +257,6 @@ _LIBCPP_PUSH_MACROS

#ifndef _LIBCPP_CXX03_LANG

#if _LIBCPP_STD_VER >= 17
#define __cpp_lib_filesystem 201703
#endif

_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM

struct _FilesystemClock {
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/forward_list
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ template <class T, class Allocator>
#include <limits>
#include <iterator>
#include <algorithm>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
3 changes: 1 addition & 2 deletions libcxx/include/functional
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited
#include <memory>
#include <tuple>
#include <utility>
#include <version>

#include <__functional_base>

Expand Down Expand Up @@ -2340,8 +2341,6 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args)

#if _LIBCPP_STD_VER > 14

#define __cpp_lib_invoke 201411

template <class _Fn, class ..._Args>
result_of_t<_Fn&&(_Args&&...)>
invoke(_Fn&& __f, _Args&&... __args)
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/iomanip
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ template <class charT, class traits, class Allocator>
#include <__config>
#include <__string>
#include <istream>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/iterator
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
#include <type_traits>
#include <cstddef>
#include <initializer_list>
#include <version>
#ifdef __APPLE__
#include <Availability.h>
#endif
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/list
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ template <class T, class Alloc>
#include <iterator>
#include <algorithm>
#include <type_traits>
#include <version>

#include <__debug>

Expand Down
1 change: 1 addition & 0 deletions libcxx/include/map
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ swap(multimap<Key, T, Compare, Allocator>& x,
#include <functional>
#include <initializer_list>
#include <type_traits>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/memory
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
# include <atomic>
#endif
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/mutex
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ template<class Callable, class ...Args>
#ifndef _LIBCPP_CXX03_LANG
#include <tuple>
#endif
#include <version>
#include <__threading_support>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/new
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void operator delete[](void* ptr, void*) noexcept;
#include <exception>
#include <type_traits>
#include <cstddef>
#include <version>
#ifdef _LIBCPP_NO_EXCEPTIONS
#include <cstdlib>
#endif
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/numeric
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ template <class M, class N>
#include <iterator>
#include <limits> // for numeric_limits
#include <functional>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/optional
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ template<class T>
#include <stdexcept>
#include <type_traits>
#include <utility>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/regex
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
#include <memory>
#include <vector>
#include <deque>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/scoped_allocator
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>

#include <__config>
#include <memory>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/set
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y)
#include <__tree>
#include <__node_handle>
#include <functional>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/shared_mutex
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ template <class Mutex>
*/

#include <__config>
#include <version>

_LIBCPP_PUSH_MACROS
#include <__undef_macros>
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/string
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++1
#include <type_traits>
#include <initializer_list>
#include <__functional_base>
#include <version>
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
#include <cstdint>
#endif
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/string_view
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ namespace std {
#include <iterator>
#include <limits>
#include <stdexcept>
#include <version>
#include <__debug>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ template <class... Types>
#include <type_traits>
#include <__functional_base>
#include <utility>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ namespace std
*/
#include <__config>
#include <cstddef>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down Expand Up @@ -4758,7 +4759,6 @@ struct __has_operator_addressof

#if _LIBCPP_STD_VER > 14

#define __cpp_lib_void_t 201411
template <class...> using void_t = void;

# ifndef _LIBCPP_HAS_NO_VARIADICS
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/unordered_map
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
#include <functional>
#include <stdexcept>
#include <tuple>
#include <version>

#include <__debug>

Expand Down
1 change: 1 addition & 0 deletions libcxx/include/unordered_set
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ template <class Value, class Hash, class Pred, class Alloc>
#include <__hash_table>
#include <__node_handle>
#include <functional>
#include <version>

#include <__debug>

Expand Down
1 change: 1 addition & 0 deletions libcxx/include/utility
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ template <size_t I>
#include <cstddef>
#include <cstring>
#include <cstdint>
#include <version>
#include <__debug>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/variant
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ namespace std {
#include <type_traits>
#include <utility>
#include <limits>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/vector
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ void swap(vector<T,Allocator>& x, vector<T,Allocator>& y)
#include <stdexcept>
#include <algorithm>
#include <cstring>
#include <version>
#include <__split_buffer>
#include <__functional_base>

Expand Down
13 changes: 13 additions & 0 deletions libcxx/include/version
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,17 @@ __cpp_lib_void_t 201411L <type_traits>
#pragma GCC system_header
#endif

#if _LIBCPP_STD_VER > 11
#endif

#if _LIBCPP_STD_VER > 14
# define __cpp_lib_atomic_is_always_lock_free 201603L
# define __cpp_lib_filesystem 201703L
# define __cpp_lib_invoke 201411L
# define __cpp_lib_void_t 201411L
#endif

#if _LIBCPP_STD_VER > 17
#endif

#endif // _LIBCPP_VERSIONH
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// <algorithm> feature macros

/* Constant Value
__cpp_lib_clamp 201603L
__cpp_lib_constexpr_swap_algorithms 201806L
__cpp_lib_parallel_algorithm 201603L
__cpp_lib_robust_nonmodifying_seq_ops 201304L
__cpp_lib_sample 201603L

*/

#include <algorithm>
#include "test_macros.h"

int main()
{
// ensure that the macros that are supposed to be defined in <algorithm> are defined.

/*
#if !defined(__cpp_lib_fooby)
# error "__cpp_lib_fooby is not defined"
#elif __cpp_lib_fooby < 201606L
# error "__cpp_lib_fooby has an invalid value"
#endif
*/
}
Loading

0 comments on commit f56972e

Please sign in to comment.