From 5d6f0738e3d540e2dc3ee34eeb66660bebca0d2c Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 15 Feb 2015 19:34:28 +0000 Subject: [PATCH] Remove LLVM_HAS_VARIADIC_TEMPLATES and all the faux variadic workarounds guarded by it. We no longer support compilers without variadic template support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229324 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/CodingStandards.rst | 2 + include/llvm/ADT/Hashing.h | 413 -------------------------------- include/llvm/ADT/Optional.h | 47 ---- include/llvm/ADT/STLExtras.h | 226 ----------------- include/llvm/ADT/SmallVector.h | 38 --- include/llvm/Support/Compiler.h | 10 - 6 files changed, 2 insertions(+), 734 deletions(-) diff --git a/docs/CodingStandards.rst b/docs/CodingStandards.rst index 9e252419234..7f35e5f159a 100644 --- a/docs/CodingStandards.rst +++ b/docs/CodingStandards.rst @@ -123,6 +123,7 @@ unlikely to be supported by our host compilers. * ``override`` and ``final``: N2928_, N3206_, N3272_ * Atomic operations and the C++11 memory model: N2429_ +* Variadic templates: N2242_ .. _N2118: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html .. _N2439: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm @@ -143,6 +144,7 @@ unlikely to be supported by our host compilers. .. _N3206: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3206.htm .. _N3272: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3272.htm .. _N2429: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2429.htm +.. _N2242: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf .. _MSVC-compatible RTTI: http://llvm.org/PR18951 The supported features in the C++11 standard libraries are less well tracked, diff --git a/include/llvm/ADT/Hashing.h b/include/llvm/ADT/Hashing.h index 1a51f4cf72d..a1e78642e94 100644 --- a/include/llvm/ADT/Hashing.h +++ b/include/llvm/ADT/Hashing.h @@ -55,12 +55,6 @@ #include #include -// Allow detecting C++11 feature availability when building with Clang without -// breaking other compilers. -#ifndef __has_feature -# define __has_feature(x) 0 -#endif - namespace llvm { /// \brief An opaque object representing a hash code. @@ -553,8 +547,6 @@ public: return buffer_ptr; } -#if defined(__has_feature) && __has_feature(__cxx_variadic_templates__) - /// \brief Recursive, variadic combining method. /// /// This function recurses through each argument, combining that argument @@ -568,218 +560,6 @@ public: return combine(length, buffer_ptr, buffer_end, args...); } -#else - // Manually expanded recursive combining methods. See variadic above for - // documentation. - - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12, - const T13 &arg13, const T14 &arg14, const T15 &arg15, - const T16 &arg16, const T17 &arg17, const T18 &arg18) { - buffer_ptr = - combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6, - arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, - arg16, arg17, arg18); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12, - const T13 &arg13, const T14 &arg14, const T15 &arg15, - const T16 &arg16, const T17 &arg17) { - buffer_ptr = - combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6, - arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, - arg16, arg17); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12, - const T13 &arg13, const T14 &arg14, const T15 &arg15, - const T16 &arg16) { - buffer_ptr = - combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6, - arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, - arg16); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12, - const T13 &arg13, const T14 &arg14, const T15 &arg15) { - buffer_ptr = - combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6, - arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12, - const T13 &arg13, const T14 &arg14) { - buffer_ptr = - combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6, - arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12, - const T13 &arg13) { - buffer_ptr = - combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6, - arg7, arg8, arg9, arg10, arg11, arg12, arg13); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12) { - buffer_ptr = - combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6, - arg7, arg8, arg9, arg10, arg11, arg12); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11) { - buffer_ptr = - combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6, - arg7, arg8, arg9, arg10, arg11); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10) { - buffer_ptr = - combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6, - arg7, arg8, arg9, arg10); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9) { - buffer_ptr = - combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6, - arg7, arg8, arg9); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8) { - buffer_ptr = - combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6, - arg7, arg8); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7) { - buffer_ptr = - combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6, - arg7); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6) { - buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5) { - buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4) { - buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2, const T3 &arg3) { - buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2, arg3); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1, const T2 &arg2) { - buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end, arg2); - } - template - hash_code combine(size_t length, char *buffer_ptr, char *buffer_end, - const T1 &arg1) { - buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1)); - return combine(length, buffer_ptr, buffer_end); - } - -#endif - /// \brief Base case for recursive, variadic combining. /// /// The base case when combining arguments recursively is reached when all @@ -808,9 +588,6 @@ public: } // namespace detail } // namespace hashing - -#if __has_feature(__cxx_variadic_templates__) - /// \brief Combine values into a single hash_code. /// /// This routine accepts a varying number of arguments of any type. It will @@ -828,196 +605,6 @@ template hash_code hash_combine(const Ts &...args) { return helper.combine(0, helper.buffer, helper.buffer + 64, args...); } -#else - -// What follows are manually exploded overloads for each argument width. See -// the above variadic definition for documentation and specification. - -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12, - const T13 &arg13, const T14 &arg14, const T15 &arg15, - const T16 &arg16, const T17 &arg17, const T18 &arg18) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3, - arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, - arg13, arg14, arg15, arg16, arg17, arg18); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12, - const T13 &arg13, const T14 &arg14, const T15 &arg15, - const T16 &arg16, const T17 &arg17) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3, - arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, - arg13, arg14, arg15, arg16, arg17); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12, - const T13 &arg13, const T14 &arg14, const T15 &arg15, - const T16 &arg16) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3, - arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, - arg13, arg14, arg15, arg16); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12, - const T13 &arg13, const T14 &arg14, const T15 &arg15) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3, - arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, - arg13, arg14, arg15); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12, - const T13 &arg13, const T14 &arg14) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3, - arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, - arg13, arg14); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12, - const T13 &arg13) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3, - arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, - arg13); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11, const T12 &arg12) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3, - arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, - arg12); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10, const T11 &arg11) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3, - arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9, - const T10 &arg10) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3, - arg4, arg5, arg6, arg7, arg8, arg9, arg10); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8, const T9 &arg9) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3, - arg4, arg5, arg6, arg7, arg8, arg9); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7, const T8 &arg8) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3, - arg4, arg5, arg6, arg7, arg8); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6, - const T7 &arg7) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3, - arg4, arg5, arg6, arg7); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5, const T6 &arg6) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, - arg1, arg2, arg3, arg4, arg5, arg6); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4, const T5 &arg5) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, - arg1, arg2, arg3, arg4, arg5); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, - const T4 &arg4) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, - arg1, arg2, arg3, arg4); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3); -} -template -hash_code hash_combine(const T1 &arg1, const T2 &arg2) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2); -} -template -hash_code hash_combine(const T1 &arg1) { - ::llvm::hashing::detail::hash_combine_recursive_helper helper; - return helper.combine(0, helper.buffer, helper.buffer + 64, arg1); -} - -#endif - - // Implementation details for implementations of hash_value overloads provided // here. namespace hashing { diff --git a/include/llvm/ADT/Optional.h b/include/llvm/ADT/Optional.h index 591872e6591..4e48bebf59a 100644 --- a/include/llvm/ADT/Optional.h +++ b/include/llvm/ADT/Optional.h @@ -70,8 +70,6 @@ public: return *this; } -#if LLVM_HAS_VARIADIC_TEMPLATES - /// Create a new object by constructing it in place with the given arguments. template void emplace(ArgTypes &&...Args) { @@ -80,51 +78,6 @@ public: new (storage.buffer) T(std::forward(Args)...); } -#else - - /// Create a new object by default-constructing it in place. - void emplace() { - reset(); - hasVal = true; - new (storage.buffer) T(); - } - - /// Create a new object by constructing it in place with the given arguments. - template - void emplace(T1 &&A1) { - reset(); - hasVal = true; - new (storage.buffer) T(std::forward(A1)); - } - - /// Create a new object by constructing it in place with the given arguments. - template - void emplace(T1 &&A1, T2 &&A2) { - reset(); - hasVal = true; - new (storage.buffer) T(std::forward(A1), std::forward(A2)); - } - - /// Create a new object by constructing it in place with the given arguments. - template - void emplace(T1 &&A1, T2 &&A2, T3 &&A3) { - reset(); - hasVal = true; - new (storage.buffer) T(std::forward(A1), std::forward(A2), - std::forward(A3)); - } - - /// Create a new object by constructing it in place with the given arguments. - template - void emplace(T1 &&A1, T2 &&A2, T3 &&A3, T4 &&A4) { - reset(); - hasVal = true; - new (storage.buffer) T(std::forward(A1), std::forward(A2), - std::forward(A3), std::forward(A4)); - } - -#endif // LLVM_HAS_VARIADIC_TEMPLATES - static inline Optional create(const T* y) { return y ? Optional(*y) : Optional(); } diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index b10a4f11f85..804bdae0c7c 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -64,8 +64,6 @@ struct greater_ptr : public std::binary_function { /// a function_ref. template class function_ref; -#if LLVM_HAS_VARIADIC_TEMPLATES - template class function_ref { Ret (*callback)(intptr_t callable, Params ...params); @@ -90,112 +88,6 @@ public: } }; -#else - -template -class function_ref { - Ret (*callback)(intptr_t callable); - intptr_t callable; - - template - static Ret callback_fn(intptr_t callable) { - return (*reinterpret_cast(callable))(); - } - -public: - template - function_ref(Callable &&callable, - typename std::enable_if< - !std::is_same::type, - function_ref>::value>::type * = nullptr) - : callback(callback_fn::type>), - callable(reinterpret_cast(&callable)) {} - Ret operator()() const { return callback(callable); } -}; - -template -class function_ref { - Ret (*callback)(intptr_t callable, Param1 param1); - intptr_t callable; - - template - static Ret callback_fn(intptr_t callable, Param1 param1) { - return (*reinterpret_cast(callable))( - std::forward(param1)); - } - -public: - template - function_ref(Callable &&callable, - typename std::enable_if< - !std::is_same::type, - function_ref>::value>::type * = nullptr) - : callback(callback_fn::type>), - callable(reinterpret_cast(&callable)) {} - Ret operator()(Param1 param1) { - return callback(callable, std::forward(param1)); - } -}; - -template -class function_ref { - Ret (*callback)(intptr_t callable, Param1 param1, Param2 param2); - intptr_t callable; - - template - static Ret callback_fn(intptr_t callable, Param1 param1, Param2 param2) { - return (*reinterpret_cast(callable))( - std::forward(param1), - std::forward(param2)); - } - -public: - template - function_ref(Callable &&callable, - typename std::enable_if< - !std::is_same::type, - function_ref>::value>::type * = nullptr) - : callback(callback_fn::type>), - callable(reinterpret_cast(&callable)) {} - Ret operator()(Param1 param1, Param2 param2) { - return callback(callable, - std::forward(param1), - std::forward(param2)); - } -}; - -template -class function_ref { - Ret (*callback)(intptr_t callable, Param1 param1, Param2 param2, Param3 param3); - intptr_t callable; - - template - static Ret callback_fn(intptr_t callable, Param1 param1, Param2 param2, - Param3 param3) { - return (*reinterpret_cast(callable))( - std::forward(param1), - std::forward(param2), - std::forward(param3)); - } - -public: - template - function_ref(Callable &&callable, - typename std::enable_if< - !std::is_same::type, - function_ref>::value>::type * = nullptr) - : callback(callback_fn::type>), - callable(reinterpret_cast(&callable)) {} - Ret operator()(Param1 param1, Param2 param2, Param3 param3) { - return callback(callable, - std::forward(param1), - std::forward(param2), - std::forward(param3)); - } -}; - -#endif - // deleter - Very very very simple method that is used to invoke operator // delete on something. It is used like this: // @@ -393,8 +285,6 @@ void DeleteContainerSeconds(Container &C) { // Extra additions to //===----------------------------------------------------------------------===// -#if LLVM_HAS_VARIADIC_TEMPLATES - // Implement make_unique according to N3656. /// \brief Constructs a `new T()` with the given args and returns a @@ -430,122 +320,6 @@ template typename std::enable_if::value != 0>::type make_unique(Args &&...) LLVM_DELETED_FUNCTION; -#else - -template -typename std::enable_if::value, std::unique_ptr>::type -make_unique() { - return std::unique_ptr(new T()); -} - -template -typename std::enable_if::value, std::unique_ptr>::type -make_unique(Arg1 &&arg1) { - return std::unique_ptr(new T(std::forward(arg1))); -} - -template -typename std::enable_if::value, std::unique_ptr>::type -make_unique(Arg1 &&arg1, Arg2 &&arg2) { - return std::unique_ptr( - new T(std::forward(arg1), std::forward(arg2))); -} - -template -typename std::enable_if::value, std::unique_ptr>::type -make_unique(Arg1 &&arg1, Arg2 &&arg2, Arg3 &&arg3) { - return std::unique_ptr(new T(std::forward(arg1), - std::forward(arg2), - std::forward(arg3))); -} - -template -typename std::enable_if::value, std::unique_ptr>::type -make_unique(Arg1 &&arg1, Arg2 &&arg2, Arg3 &&arg3, Arg4 &&arg4) { - return std::unique_ptr( - new T(std::forward(arg1), std::forward(arg2), - std::forward(arg3), std::forward(arg4))); -} - -template -typename std::enable_if::value, std::unique_ptr>::type -make_unique(Arg1 &&arg1, Arg2 &&arg2, Arg3 &&arg3, Arg4 &&arg4, Arg5 &&arg5) { - return std::unique_ptr( - new T(std::forward(arg1), std::forward(arg2), - std::forward(arg3), std::forward(arg4), - std::forward(arg5))); -} - -template -typename std::enable_if::value, std::unique_ptr>::type -make_unique(Arg1 &&arg1, Arg2 &&arg2, Arg3 &&arg3, Arg4 &&arg4, Arg5 &&arg5, - Arg6 &&arg6) { - return std::unique_ptr( - new T(std::forward(arg1), std::forward(arg2), - std::forward(arg3), std::forward(arg4), - std::forward(arg5), std::forward(arg6))); -} - -template -typename std::enable_if::value, std::unique_ptr>::type -make_unique(Arg1 &&arg1, Arg2 &&arg2, Arg3 &&arg3, Arg4 &&arg4, Arg5 &&arg5, - Arg6 &&arg6, Arg7 &&arg7) { - return std::unique_ptr( - new T(std::forward(arg1), std::forward(arg2), - std::forward(arg3), std::forward(arg4), - std::forward(arg5), std::forward(arg6), - std::forward(arg7))); -} - -template -typename std::enable_if::value, std::unique_ptr>::type -make_unique(Arg1 &&arg1, Arg2 &&arg2, Arg3 &&arg3, Arg4 &&arg4, Arg5 &&arg5, - Arg6 &&arg6, Arg7 &&arg7, Arg8 &&arg8) { - return std::unique_ptr( - new T(std::forward(arg1), std::forward(arg2), - std::forward(arg3), std::forward(arg4), - std::forward(arg5), std::forward(arg6), - std::forward(arg7), std::forward(arg8))); -} - -template -typename std::enable_if::value, std::unique_ptr>::type -make_unique(Arg1 &&arg1, Arg2 &&arg2, Arg3 &&arg3, Arg4 &&arg4, Arg5 &&arg5, - Arg6 &&arg6, Arg7 &&arg7, Arg8 &&arg8, Arg9 &&arg9) { - return std::unique_ptr( - new T(std::forward(arg1), std::forward(arg2), - std::forward(arg3), std::forward(arg4), - std::forward(arg5), std::forward(arg6), - std::forward(arg7), std::forward(arg8), - std::forward(arg9))); -} - -template -typename std::enable_if::value, std::unique_ptr>::type -make_unique(Arg1 &&arg1, Arg2 &&arg2, Arg3 &&arg3, Arg4 &&arg4, Arg5 &&arg5, - Arg6 &&arg6, Arg7 &&arg7, Arg8 &&arg8, Arg9 &&arg9, Arg10 &&arg10) { - return std::unique_ptr( - new T(std::forward(arg1), std::forward(arg2), - std::forward(arg3), std::forward(arg4), - std::forward(arg5), std::forward(arg6), - std::forward(arg7), std::forward(arg8), - std::forward(arg9), std::forward(arg10))); -} - -template -typename std::enable_if::value &&std::extent::value == 0, - std::unique_ptr>::type -make_unique(size_t n) { - return std::unique_ptr(new typename std::remove_extent::type[n]()); -} - -#endif - struct FreeDeleter { void operator()(void* v) { ::free(v); diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index 086f8454daf..c35713bddaa 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -633,50 +633,12 @@ public: return I; } -#if LLVM_HAS_VARIADIC_TEMPLATES template void emplace_back(ArgTypes &&... Args) { if (LLVM_UNLIKELY(this->EndX >= this->CapacityX)) this->grow(); ::new ((void *)this->end()) T(std::forward(Args)...); this->setEnd(this->end() + 1); } -#else -private: - template void emplace_back_impl(Constructor construct) { - if (LLVM_UNLIKELY(this->EndX >= this->CapacityX)) - this->grow(); - construct((void *)this->end()); - this->setEnd(this->end() + 1); - } - -public: - void emplace_back() { - emplace_back_impl([](void *Mem) { ::new (Mem) T(); }); - } - template void emplace_back(T1 &&A1) { - emplace_back_impl([&](void *Mem) { ::new (Mem) T(std::forward(A1)); }); - } - template void emplace_back(T1 &&A1, T2 &&A2) { - emplace_back_impl([&](void *Mem) { - ::new (Mem) T(std::forward(A1), std::forward(A2)); - }); - } - template - void emplace_back(T1 &&A1, T2 &&A2, T3 &&A3) { - T(std::forward(A1), std::forward(A2), std::forward(A3)); - emplace_back_impl([&](void *Mem) { - ::new (Mem) - T(std::forward(A1), std::forward(A2), std::forward(A3)); - }); - } - template - void emplace_back(T1 &&A1, T2 &&A2, T3 &&A3, T4 &&A4) { - emplace_back_impl([&](void *Mem) { - ::new (Mem) T(std::forward(A1), std::forward(A2), - std::forward(A3), std::forward(A4)); - }); - } -#endif // LLVM_HAS_VARIADIC_TEMPLATES SmallVectorImpl &operator=(const SmallVectorImpl &RHS); diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 507b86ae281..40bf25ad63d 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -82,16 +82,6 @@ #define LLVM_HAS_RVALUE_REFERENCE_THIS 0 #endif -/// \macro LLVM_HAS_VARIADIC_TEMPLATES -/// \brief Does this compiler support variadic templates. -/// -/// Implies LLVM_HAS_RVALUE_REFERENCES and the existence of std::forward. -#if __has_feature(cxx_variadic_templates) || LLVM_MSC_PREREQ(1800) -# define LLVM_HAS_VARIADIC_TEMPLATES 1 -#else -# define LLVM_HAS_VARIADIC_TEMPLATES 0 -#endif - /// Expands to '&' if r-value references are supported. /// /// This can be used to provide l-value/r-value overrides of member functions. -- 2.34.1