[C++11] Replace LLVM-style type traits with C++11 standard ones.

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203242 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer
2014-03-07 14:42:25 +00:00
parent 122a970111
commit c1dafe8dc3
18 changed files with 119 additions and 133 deletions

View File

@@ -223,8 +223,8 @@ steps:
[...] [...]
template <class T> template <class T>
static bool classof(const T *, static bool classof(const T *,
::llvm::enable_if_c< ::std::enable_if<
::llvm::is_base_of<Foo, T>::value ::std::is_base_of<Foo, T>::value
>::type* = 0) { return true; } >::type* = 0) { return true; }
[...] [...]
}; };

View File

@@ -977,7 +977,8 @@ class DenseMapIterator {
friend class DenseMapIterator<KeyT, ValueT, KeyInfoT, true>; friend class DenseMapIterator<KeyT, ValueT, KeyInfoT, true>;
public: public:
typedef ptrdiff_t difference_type; typedef ptrdiff_t difference_type;
typedef typename conditional<IsConst, const Bucket, Bucket>::type value_type; typedef typename std::conditional<IsConst, const Bucket, Bucket>::type
value_type;
typedef value_type *pointer; typedef value_type *pointer;
typedef value_type &reference; typedef value_type &reference;
typedef std::forward_iterator_tag iterator_category; typedef std::forward_iterator_tag iterator_category;

View File

@@ -109,7 +109,8 @@ public:
/// differing argument types even if they would implicit promote to a common /// differing argument types even if they would implicit promote to a common
/// type without changing the value. /// type without changing the value.
template <typename T> template <typename T>
typename enable_if<is_integral_or_enum<T>, hash_code>::type hash_value(T value); typename std::enable_if<is_integral_or_enum<T>::value, hash_code>::type
hash_value(T value);
/// \brief Compute a hash_code for a pointer's address. /// \brief Compute a hash_code for a pointer's address.
/// ///
@@ -352,24 +353,24 @@ inline size_t get_execution_seed() {
// and pointers, but there are platforms where it doesn't and we would like to // and pointers, but there are platforms where it doesn't and we would like to
// support user-defined types which happen to satisfy this property. // support user-defined types which happen to satisfy this property.
template <typename T> struct is_hashable_data template <typename T> struct is_hashable_data
: integral_constant<bool, ((is_integral_or_enum<T>::value || : std::integral_constant<bool, ((is_integral_or_enum<T>::value ||
is_pointer<T>::value) && std::is_pointer<T>::value) &&
64 % sizeof(T) == 0)> {}; 64 % sizeof(T) == 0)> {};
// Special case std::pair to detect when both types are viable and when there // Special case std::pair to detect when both types are viable and when there
// is no alignment-derived padding in the pair. This is a bit of a lie because // is no alignment-derived padding in the pair. This is a bit of a lie because
// std::pair isn't truly POD, but it's close enough in all reasonable // std::pair isn't truly POD, but it's close enough in all reasonable
// implementations for our use case of hashing the underlying data. // implementations for our use case of hashing the underlying data.
template <typename T, typename U> struct is_hashable_data<std::pair<T, U> > template <typename T, typename U> struct is_hashable_data<std::pair<T, U> >
: integral_constant<bool, (is_hashable_data<T>::value && : std::integral_constant<bool, (is_hashable_data<T>::value &&
is_hashable_data<U>::value && is_hashable_data<U>::value &&
(sizeof(T) + sizeof(U)) == (sizeof(T) + sizeof(U)) ==
sizeof(std::pair<T, U>))> {}; sizeof(std::pair<T, U>))> {};
/// \brief Helper to get the hashable data representation for a type. /// \brief Helper to get the hashable data representation for a type.
/// This variant is enabled when the type itself can be used. /// This variant is enabled when the type itself can be used.
template <typename T> template <typename T>
typename enable_if<is_hashable_data<T>, T>::type typename std::enable_if<is_hashable_data<T>::value, T>::type
get_hashable_data(const T &value) { get_hashable_data(const T &value) {
return value; return value;
} }
@@ -377,7 +378,7 @@ get_hashable_data(const T &value) {
/// This variant is enabled when we must first call hash_value and use the /// This variant is enabled when we must first call hash_value and use the
/// result as our data. /// result as our data.
template <typename T> template <typename T>
typename enable_if_c<!is_hashable_data<T>::value, size_t>::type typename std::enable_if<!is_hashable_data<T>::value, size_t>::type
get_hashable_data(const T &value) { get_hashable_data(const T &value) {
using ::llvm::hash_value; using ::llvm::hash_value;
return hash_value(value); return hash_value(value);
@@ -451,7 +452,7 @@ hash_code hash_combine_range_impl(InputIteratorT first, InputIteratorT last) {
/// are stored in contiguous memory, this routine avoids copying each value /// are stored in contiguous memory, this routine avoids copying each value
/// and directly reads from the underlying memory. /// and directly reads from the underlying memory.
template <typename ValueT> template <typename ValueT>
typename enable_if<is_hashable_data<ValueT>, hash_code>::type typename std::enable_if<is_hashable_data<ValueT>::value, hash_code>::type
hash_combine_range_impl(ValueT *first, ValueT *last) { hash_combine_range_impl(ValueT *first, ValueT *last) {
const size_t seed = get_execution_seed(); const size_t seed = get_execution_seed();
const char *s_begin = reinterpret_cast<const char *>(first); const char *s_begin = reinterpret_cast<const char *>(first);
@@ -734,7 +735,7 @@ inline hash_code hash_integer_value(uint64_t value) {
// Declared and documented above, but defined here so that any of the hashing // Declared and documented above, but defined here so that any of the hashing
// infrastructure is available. // infrastructure is available.
template <typename T> template <typename T>
typename enable_if<is_integral_or_enum<T>, hash_code>::type typename std::enable_if<is_integral_or_enum<T>::value, hash_code>::type
hash_value(T value) { hash_value(T value) {
return ::llvm::hashing::detail::hash_integer_value(value); return ::llvm::hashing::detail::hash_integer_value(value);
} }

View File

@@ -11,7 +11,6 @@
#define LLVM_ADT_STRINGREF_H #define LLVM_ADT_STRINGREF_H
#include "llvm/Support/Allocator.h" #include "llvm/Support/Allocator.h"
#include "llvm/Support/type_traits.h"
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
@@ -341,7 +340,7 @@ namespace llvm {
/// this returns true to signify the error. The string is considered /// this returns true to signify the error. The string is considered
/// erroneous if empty or if it overflows T. /// erroneous if empty or if it overflows T.
template <typename T> template <typename T>
typename enable_if_c<std::numeric_limits<T>::is_signed, bool>::type typename std::enable_if<std::numeric_limits<T>::is_signed, bool>::type
getAsInteger(unsigned Radix, T &Result) const { getAsInteger(unsigned Radix, T &Result) const {
long long LLVal; long long LLVal;
if (getAsSignedInteger(*this, Radix, LLVal) || if (getAsSignedInteger(*this, Radix, LLVal) ||
@@ -352,7 +351,7 @@ namespace llvm {
} }
template <typename T> template <typename T>
typename enable_if_c<!std::numeric_limits<T>::is_signed, bool>::type typename std::enable_if<!std::numeric_limits<T>::is_signed, bool>::type
getAsInteger(unsigned Radix, T &Result) const { getAsInteger(unsigned Radix, T &Result) const {
unsigned long long ULLVal; unsigned long long ULLVal;
if (getAsUnsignedInteger(*this, Radix, ULLVal) || if (getAsUnsignedInteger(*this, Radix, ULLVal) ||

View File

@@ -496,13 +496,11 @@ public:
//@{ //@{
template <bool IsConst> template <bool IsConst>
class block_iterator_wrapper class block_iterator_wrapper
: public df_iterator<typename conditional<IsConst, : public df_iterator<typename std::conditional<IsConst, const BasicBlock,
const BasicBlock, BasicBlock>::type *> {
BasicBlock>::type*> { typedef df_iterator<typename std::conditional<IsConst, const BasicBlock,
typedef df_iterator<typename conditional<IsConst, BasicBlock>::type *> super;
const BasicBlock,
BasicBlock>::type*>
super;
public: public:
typedef block_iterator_wrapper<IsConst> Self; typedef block_iterator_wrapper<IsConst> Self;
typedef typename super::pointer pointer; typedef typename super::pointer pointer;

View File

@@ -198,7 +198,7 @@ class ValueMapCallbackVH : public CallbackVH {
friend class ValueMap<KeyT, ValueT, Config>; friend class ValueMap<KeyT, ValueT, Config>;
friend struct DenseMapInfo<ValueMapCallbackVH>; friend struct DenseMapInfo<ValueMapCallbackVH>;
typedef ValueMap<KeyT, ValueT, Config> ValueMapT; typedef ValueMap<KeyT, ValueT, Config> ValueMapT;
typedef typename llvm::remove_pointer<KeyT>::type KeySansPointerT; typedef typename std::remove_pointer<KeyT>::type KeySansPointerT;
ValueMapT *Map; ValueMapT *Map;

View File

@@ -51,8 +51,8 @@ template <class ELFT>
class ELFFile { class ELFFile {
public: public:
LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
typedef typename conditional<ELFT::Is64Bits, typedef typename std::conditional<ELFT::Is64Bits,
uint64_t, uint32_t>::type uintX_t; uint64_t, uint32_t>::type uintX_t;
/// \brief Iterate over constant sized entities. /// \brief Iterate over constant sized entities.
template <class EntT> template <class EntT>

View File

@@ -41,10 +41,10 @@ inline error_code make_error_code(object_error e) {
} // end namespace object. } // end namespace object.
template <> struct is_error_code_enum<object::object_error> : true_type { }; template <> struct is_error_code_enum<object::object_error> : std::true_type {};
template <> struct is_error_code_enum<object::object_error::Impl> : true_type { template <>
}; struct is_error_code_enum<object::object_error::Impl> : std::true_type {};
} // end namespace llvm. } // end namespace llvm.

View File

@@ -59,11 +59,8 @@ struct isa_impl {
/// \brief Always allow upcasts, and perform no dynamic check for them. /// \brief Always allow upcasts, and perform no dynamic check for them.
template <typename To, typename From> template <typename To, typename From>
struct isa_impl<To, From, struct isa_impl<
typename enable_if< To, From, typename std::enable_if<std::is_base_of<To, From>::value>::type> {
llvm::is_base_of<To, From>
>::type
> {
static inline bool doit(const From &) { return true; } static inline bool doit(const From &) { return true; }
}; };
@@ -209,7 +206,7 @@ template<class To, class FromTy> struct cast_convert_val<To,FromTy,FromTy> {
template <class X> struct is_simple_type { template <class X> struct is_simple_type {
static const bool value = static const bool value =
is_same<X, typename simplify_type<X>::SimpleType>::value; std::is_same<X, typename simplify_type<X>::SimpleType>::value;
}; };
// cast<X> - Return the argument parameter cast to the specified type. This // cast<X> - Return the argument parameter cast to the specified type. This
@@ -220,8 +217,8 @@ template <class X> struct is_simple_type {
// cast<Instruction>(myVal)->getParent() // cast<Instruction>(myVal)->getParent()
// //
template <class X, class Y> template <class X, class Y>
inline typename enable_if_c<!is_simple_type<Y>::value, inline typename std::enable_if<!is_simple_type<Y>::value,
typename cast_retty<X, const Y>::ret_type>::type typename cast_retty<X, const Y>::ret_type>::type
cast(const Y &Val) { cast(const Y &Val) {
assert(isa<X>(Val) && "cast<Ty>() argument of incompatible type!"); assert(isa<X>(Val) && "cast<Ty>() argument of incompatible type!");
return cast_convert_val< return cast_convert_val<
@@ -263,7 +260,7 @@ cast_or_null(Y *Val) {
// //
template <class X, class Y> template <class X, class Y>
LLVM_ATTRIBUTE_UNUSED_RESULT inline typename enable_if_c< LLVM_ATTRIBUTE_UNUSED_RESULT inline typename std::enable_if<
!is_simple_type<Y>::value, typename cast_retty<X, const Y>::ret_type>::type !is_simple_type<Y>::value, typename cast_retty<X, const Y>::ret_type>::type
dyn_cast(const Y &Val) { dyn_cast(const Y &Val) {
return isa<X>(Val) ? cast<X>(Val) : 0; return isa<X>(Val) ? cast<X>(Val) : 0;

View File

@@ -24,7 +24,6 @@
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include "llvm/Support/type_traits.h"
#include <cassert> #include <cassert>
#include <climits> #include <climits>
#include <cstdarg> #include <cstdarg>
@@ -422,7 +421,7 @@ struct OptionValueBase<DataType, false> : OptionValueCopy<DataType> {
// Top-level option class. // Top-level option class.
template<class DataType> template<class DataType>
struct OptionValue : OptionValueBase<DataType, is_class<DataType>::value> { struct OptionValue : OptionValueBase<DataType, std::is_class<DataType>::value> {
OptionValue() {} OptionValue() {}
OptionValue(const DataType& V) { OptionValue(const DataType& V) {
@@ -1156,7 +1155,7 @@ template <class DataType, bool ExternalStorage = false,
class ParserClass = parser<DataType> > class ParserClass = parser<DataType> >
class opt : public Option, class opt : public Option,
public opt_storage<DataType, ExternalStorage, public opt_storage<DataType, ExternalStorage,
is_class<DataType>::value> { std::is_class<DataType>::value> {
ParserClass Parser; ParserClass Parser;
bool handleOccurrence(unsigned pos, StringRef ArgName, bool handleOccurrence(unsigned pos, StringRef ArgName,

View File

@@ -17,7 +17,6 @@
#include "llvm/Support/AlignOf.h" #include "llvm/Support/AlignOf.h"
#include "llvm/Support/Host.h" #include "llvm/Support/Host.h"
#include "llvm/Support/SwapByteOrder.h" #include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/type_traits.h"
namespace llvm { namespace llvm {
namespace support { namespace support {

View File

@@ -19,7 +19,6 @@
#include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerIntPair.h"
#include "llvm/Support/AlignOf.h" #include "llvm/Support/AlignOf.h"
#include "llvm/Support/system_error.h" #include "llvm/Support/system_error.h"
#include "llvm/Support/type_traits.h"
#include <cassert> #include <cassert>
#include <type_traits> #include <type_traits>
@@ -82,26 +81,22 @@ public:
template<class T> template<class T>
class ErrorOr { class ErrorOr {
template <class OtherT> friend class ErrorOr; template <class OtherT> friend class ErrorOr;
static const bool isRef = is_reference<T>::value; static const bool isRef = std::is_reference<T>::value;
typedef ReferenceStorage<typename remove_reference<T>::type> wrap; typedef ReferenceStorage<typename std::remove_reference<T>::type> wrap;
public: public:
typedef typename typedef typename std::conditional<isRef, wrap, T>::type storage_type;
conditional< isRef
, wrap
, T
>::type storage_type;
private: private:
typedef typename remove_reference<T>::type &reference; typedef typename std::remove_reference<T>::type &reference;
typedef const typename remove_reference<T>::type &const_reference; typedef const typename std::remove_reference<T>::type &const_reference;
typedef typename remove_reference<T>::type *pointer; typedef typename std::remove_reference<T>::type *pointer;
public: public:
template <class E> template <class E>
ErrorOr(E ErrorCode, typename enable_if_c<is_error_code_enum<E>::value || ErrorOr(E ErrorCode, typename std::enable_if<is_error_code_enum<E>::value ||
is_error_condition_enum<E>::value, is_error_condition_enum<E>::value,
void *>::type = 0) void *>::type = 0)
: HasError(true) { : HasError(true) {
new (getErrorStorage()) error_code(make_error_code(ErrorCode)); new (getErrorStorage()) error_code(make_error_code(ErrorCode));
} }
@@ -270,8 +265,8 @@ private:
}; };
template<class T, class E> template<class T, class E>
typename enable_if_c<is_error_code_enum<E>::value || typename std::enable_if<is_error_code_enum<E>::value ||
is_error_condition_enum<E>::value, bool>::type is_error_condition_enum<E>::value, bool>::type
operator ==(ErrorOr<T> &Err, E Code) { operator ==(ErrorOr<T> &Err, E Code) {
return error_code(Err) == Code; return error_code(Err) == Code;
} }

View File

@@ -16,7 +16,6 @@
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include "llvm/Support/SwapByteOrder.h" #include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/type_traits.h"
#include <cstring> #include <cstring>
#ifdef _MSC_VER #ifdef _MSC_VER
@@ -43,8 +42,8 @@ enum ZeroBehavior {
/// \param ZB the behavior on an input of 0. Only ZB_Width and ZB_Undefined are /// \param ZB the behavior on an input of 0. Only ZB_Width and ZB_Undefined are
/// valid arguments. /// valid arguments.
template <typename T> template <typename T>
typename enable_if_c<std::numeric_limits<T>::is_integer && typename std::enable_if<std::numeric_limits<T>::is_integer &&
!std::numeric_limits<T>::is_signed, std::size_t>::type !std::numeric_limits<T>::is_signed, std::size_t>::type
countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) { countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
(void)ZB; (void)ZB;
@@ -70,8 +69,8 @@ countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
// Disable signed. // Disable signed.
template <typename T> template <typename T>
typename enable_if_c<std::numeric_limits<T>::is_integer && typename std::enable_if<std::numeric_limits<T>::is_integer &&
std::numeric_limits<T>::is_signed, std::size_t>::type std::numeric_limits<T>::is_signed, std::size_t>::type
countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) LLVM_DELETED_FUNCTION; countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) LLVM_DELETED_FUNCTION;
#if __GNUC__ >= 4 || _MSC_VER #if __GNUC__ >= 4 || _MSC_VER
@@ -114,8 +113,8 @@ inline std::size_t countTrailingZeros<uint64_t>(uint64_t Val, ZeroBehavior ZB) {
/// \param ZB the behavior on an input of 0. Only ZB_Width and ZB_Undefined are /// \param ZB the behavior on an input of 0. Only ZB_Width and ZB_Undefined are
/// valid arguments. /// valid arguments.
template <typename T> template <typename T>
typename enable_if_c<std::numeric_limits<T>::is_integer && typename std::enable_if<std::numeric_limits<T>::is_integer &&
!std::numeric_limits<T>::is_signed, std::size_t>::type !std::numeric_limits<T>::is_signed, std::size_t>::type
countLeadingZeros(T Val, ZeroBehavior ZB = ZB_Width) { countLeadingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
(void)ZB; (void)ZB;
@@ -136,8 +135,8 @@ countLeadingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
// Disable signed. // Disable signed.
template <typename T> template <typename T>
typename enable_if_c<std::numeric_limits<T>::is_integer && typename std::enable_if<std::numeric_limits<T>::is_integer &&
std::numeric_limits<T>::is_signed, std::size_t>::type std::numeric_limits<T>::is_signed, std::size_t>::type
countLeadingZeros(T Val, ZeroBehavior ZB = ZB_Width) LLVM_DELETED_FUNCTION; countLeadingZeros(T Val, ZeroBehavior ZB = ZB_Width) LLVM_DELETED_FUNCTION;
#if __GNUC__ >= 4 || _MSC_VER #if __GNUC__ >= 4 || _MSC_VER
@@ -180,8 +179,8 @@ inline std::size_t countLeadingZeros<uint64_t>(uint64_t Val, ZeroBehavior ZB) {
/// \param ZB the behavior on an input of 0. Only ZB_Max and ZB_Undefined are /// \param ZB the behavior on an input of 0. Only ZB_Max and ZB_Undefined are
/// valid arguments. /// valid arguments.
template <typename T> template <typename T>
typename enable_if_c<std::numeric_limits<T>::is_integer && typename std::enable_if<std::numeric_limits<T>::is_integer &&
!std::numeric_limits<T>::is_signed, T>::type !std::numeric_limits<T>::is_signed, T>::type
findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) { findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) {
if (ZB == ZB_Max && Val == 0) if (ZB == ZB_Max && Val == 0)
return std::numeric_limits<T>::max(); return std::numeric_limits<T>::max();
@@ -191,8 +190,8 @@ findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) {
// Disable signed. // Disable signed.
template <typename T> template <typename T>
typename enable_if_c<std::numeric_limits<T>::is_integer && typename std::enable_if<std::numeric_limits<T>::is_integer &&
std::numeric_limits<T>::is_signed, T>::type std::numeric_limits<T>::is_signed, T>::type
findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) LLVM_DELETED_FUNCTION; findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) LLVM_DELETED_FUNCTION;
/// \brief Get the index of the last set bit starting from the least /// \brief Get the index of the last set bit starting from the least
@@ -203,8 +202,8 @@ findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) LLVM_DELETED_FUNCTION;
/// \param ZB the behavior on an input of 0. Only ZB_Max and ZB_Undefined are /// \param ZB the behavior on an input of 0. Only ZB_Max and ZB_Undefined are
/// valid arguments. /// valid arguments.
template <typename T> template <typename T>
typename enable_if_c<std::numeric_limits<T>::is_integer && typename std::enable_if<std::numeric_limits<T>::is_integer &&
!std::numeric_limits<T>::is_signed, T>::type !std::numeric_limits<T>::is_signed, T>::type
findLastSet(T Val, ZeroBehavior ZB = ZB_Max) { findLastSet(T Val, ZeroBehavior ZB = ZB_Max) {
if (ZB == ZB_Max && Val == 0) if (ZB == ZB_Max && Val == 0)
return std::numeric_limits<T>::max(); return std::numeric_limits<T>::max();
@@ -217,8 +216,8 @@ findLastSet(T Val, ZeroBehavior ZB = ZB_Max) {
// Disable signed. // Disable signed.
template <typename T> template <typename T>
typename enable_if_c<std::numeric_limits<T>::is_integer && typename std::enable_if<std::numeric_limits<T>::is_integer &&
std::numeric_limits<T>::is_signed, T>::type std::numeric_limits<T>::is_signed, T>::type
findLastSet(T Val, ZeroBehavior ZB = ZB_Max) LLVM_DELETED_FUNCTION; findLastSet(T Val, ZeroBehavior ZB = ZB_Max) LLVM_DELETED_FUNCTION;
/// \brief Macro compressed bit reversal table for 256 bits. /// \brief Macro compressed bit reversal table for 256 bits.

View File

@@ -23,8 +23,6 @@
#include "llvm/Support/YAMLParser.h" #include "llvm/Support/YAMLParser.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Support/system_error.h" #include "llvm/Support/system_error.h"
#include "llvm/Support/type_traits.h"
namespace llvm { namespace llvm {
namespace yaml { namespace yaml {
@@ -266,7 +264,7 @@ public:
// has_FlowTraits<int> will cause an error with some compilers because // has_FlowTraits<int> will cause an error with some compilers because
// it subclasses int. Using this wrapper only instantiates the // it subclasses int. Using this wrapper only instantiates the
// real has_FlowTraits only if the template type is a class. // real has_FlowTraits only if the template type is a class.
template <typename T, bool Enabled = llvm::is_class<T>::value> template <typename T, bool Enabled = std::is_class<T>::value>
class has_FlowTraits class has_FlowTraits
{ {
public: public:
@@ -296,7 +294,7 @@ public:
// Test if SequenceTraits<T> is defined on type T // Test if SequenceTraits<T> is defined on type T
template<typename T> template<typename T>
struct has_SequenceTraits : public llvm::integral_constant<bool, struct has_SequenceTraits : public std::integral_constant<bool,
has_SequenceMethodTraits<T>::value > { }; has_SequenceMethodTraits<T>::value > { };
@@ -320,7 +318,7 @@ public:
template<typename T> template<typename T>
struct missingTraits : public llvm::integral_constant<bool, struct missingTraits : public std::integral_constant<bool,
!has_ScalarEnumerationTraits<T>::value !has_ScalarEnumerationTraits<T>::value
&& !has_ScalarBitSetTraits<T>::value && !has_ScalarBitSetTraits<T>::value
&& !has_ScalarTraits<T>::value && !has_ScalarTraits<T>::value
@@ -329,12 +327,12 @@ struct missingTraits : public llvm::integral_constant<bool,
&& !has_DocumentListTraits<T>::value > {}; && !has_DocumentListTraits<T>::value > {};
template<typename T> template<typename T>
struct validatedMappingTraits : public llvm::integral_constant<bool, struct validatedMappingTraits : public std::integral_constant<bool,
has_MappingTraits<T>::value has_MappingTraits<T>::value
&& has_MappingValidateTraits<T>::value> {}; && has_MappingValidateTraits<T>::value> {};
template<typename T> template<typename T>
struct unvalidatedMappingTraits : public llvm::integral_constant<bool, struct unvalidatedMappingTraits : public std::integral_constant<bool,
has_MappingTraits<T>::value has_MappingTraits<T>::value
&& !has_MappingValidateTraits<T>::value> {}; && !has_MappingValidateTraits<T>::value> {};
// Base class for Input and Output. // Base class for Input and Output.
@@ -414,7 +412,7 @@ public:
} }
template <typename T> template <typename T>
typename llvm::enable_if_c<has_SequenceTraits<T>::value,void>::type typename std::enable_if<has_SequenceTraits<T>::value,void>::type
mapOptional(const char* Key, T& Val) { mapOptional(const char* Key, T& Val) {
// omit key/value instead of outputting empty sequence // omit key/value instead of outputting empty sequence
if ( this->canElideEmptySequence() && !(Val.begin() != Val.end()) ) if ( this->canElideEmptySequence() && !(Val.begin() != Val.end()) )
@@ -423,7 +421,7 @@ public:
} }
template <typename T> template <typename T>
typename llvm::enable_if_c<!has_SequenceTraits<T>::value,void>::type typename std::enable_if<!has_SequenceTraits<T>::value,void>::type
mapOptional(const char* Key, T& Val) { mapOptional(const char* Key, T& Val) {
this->processKey(Key, Val, false); this->processKey(Key, Val, false);
} }
@@ -468,7 +466,7 @@ private:
template<typename T> template<typename T>
typename llvm::enable_if_c<has_ScalarEnumerationTraits<T>::value,void>::type typename std::enable_if<has_ScalarEnumerationTraits<T>::value,void>::type
yamlize(IO &io, T &Val, bool) { yamlize(IO &io, T &Val, bool) {
io.beginEnumScalar(); io.beginEnumScalar();
ScalarEnumerationTraits<T>::enumeration(io, Val); ScalarEnumerationTraits<T>::enumeration(io, Val);
@@ -476,7 +474,7 @@ yamlize(IO &io, T &Val, bool) {
} }
template<typename T> template<typename T>
typename llvm::enable_if_c<has_ScalarBitSetTraits<T>::value,void>::type typename std::enable_if<has_ScalarBitSetTraits<T>::value,void>::type
yamlize(IO &io, T &Val, bool) { yamlize(IO &io, T &Val, bool) {
bool DoClear; bool DoClear;
if ( io.beginBitSetScalar(DoClear) ) { if ( io.beginBitSetScalar(DoClear) ) {
@@ -489,7 +487,7 @@ yamlize(IO &io, T &Val, bool) {
template<typename T> template<typename T>
typename llvm::enable_if_c<has_ScalarTraits<T>::value,void>::type typename std::enable_if<has_ScalarTraits<T>::value,void>::type
yamlize(IO &io, T &Val, bool) { yamlize(IO &io, T &Val, bool) {
if ( io.outputting() ) { if ( io.outputting() ) {
std::string Storage; std::string Storage;
@@ -510,7 +508,7 @@ yamlize(IO &io, T &Val, bool) {
template<typename T> template<typename T>
typename llvm::enable_if_c<validatedMappingTraits<T>::value, void>::type typename std::enable_if<validatedMappingTraits<T>::value, void>::type
yamlize(IO &io, T &Val, bool) { yamlize(IO &io, T &Val, bool) {
io.beginMapping(); io.beginMapping();
if (io.outputting()) { if (io.outputting()) {
@@ -530,7 +528,7 @@ yamlize(IO &io, T &Val, bool) {
} }
template<typename T> template<typename T>
typename llvm::enable_if_c<unvalidatedMappingTraits<T>::value, void>::type typename std::enable_if<unvalidatedMappingTraits<T>::value, void>::type
yamlize(IO &io, T &Val, bool) { yamlize(IO &io, T &Val, bool) {
io.beginMapping(); io.beginMapping();
MappingTraits<T>::mapping(io, Val); MappingTraits<T>::mapping(io, Val);
@@ -538,13 +536,13 @@ yamlize(IO &io, T &Val, bool) {
} }
template<typename T> template<typename T>
typename llvm::enable_if_c<missingTraits<T>::value, void>::type typename std::enable_if<missingTraits<T>::value, void>::type
yamlize(IO &io, T &Val, bool) { yamlize(IO &io, T &Val, bool) {
char missing_yaml_trait_for_type[sizeof(MissingTrait<T>)]; char missing_yaml_trait_for_type[sizeof(MissingTrait<T>)];
} }
template<typename T> template<typename T>
typename llvm::enable_if_c<has_SequenceTraits<T>::value,void>::type typename std::enable_if<has_SequenceTraits<T>::value,void>::type
yamlize(IO &io, T &Seq, bool) { yamlize(IO &io, T &Seq, bool) {
if ( has_FlowTraits< SequenceTraits<T> >::value ) { if ( has_FlowTraits< SequenceTraits<T> >::value ) {
unsigned incnt = io.beginFlowSequence(); unsigned incnt = io.beginFlowSequence();
@@ -990,7 +988,7 @@ struct ScalarTraits<Hex64> {
// Define non-member operator>> so that Input can stream in a document list. // Define non-member operator>> so that Input can stream in a document list.
template <typename T> template <typename T>
inline inline
typename llvm::enable_if_c<has_DocumentListTraits<T>::value,Input &>::type typename std::enable_if<has_DocumentListTraits<T>::value, Input &>::type
operator>>(Input &yin, T &docList) { operator>>(Input &yin, T &docList) {
int i = 0; int i = 0;
while ( yin.setCurrentDocument() ) { while ( yin.setCurrentDocument() ) {
@@ -1006,7 +1004,7 @@ operator>>(Input &yin, T &docList) {
// Define non-member operator>> so that Input can stream in a map as a document. // Define non-member operator>> so that Input can stream in a map as a document.
template <typename T> template <typename T>
inline inline
typename llvm::enable_if_c<has_MappingTraits<T>::value,Input &>::type typename std::enable_if<has_MappingTraits<T>::value, Input &>::type
operator>>(Input &yin, T &docMap) { operator>>(Input &yin, T &docMap) {
yin.setCurrentDocument(); yin.setCurrentDocument();
yamlize(yin, docMap, true); yamlize(yin, docMap, true);
@@ -1017,7 +1015,7 @@ operator>>(Input &yin, T &docMap) {
// a document. // a document.
template <typename T> template <typename T>
inline inline
typename llvm::enable_if_c<has_SequenceTraits<T>::value,Input &>::type typename std::enable_if<has_SequenceTraits<T>::value, Input &>::type
operator>>(Input &yin, T &docSeq) { operator>>(Input &yin, T &docSeq) {
if (yin.setCurrentDocument()) if (yin.setCurrentDocument())
yamlize(yin, docSeq, true); yamlize(yin, docSeq, true);
@@ -1027,7 +1025,7 @@ operator>>(Input &yin, T &docSeq) {
// Provide better error message about types missing a trait specialization // Provide better error message about types missing a trait specialization
template <typename T> template <typename T>
inline inline
typename llvm::enable_if_c<missingTraits<T>::value,Input &>::type typename std::enable_if<missingTraits<T>::value, Input &>::type
operator>>(Input &yin, T &docSeq) { operator>>(Input &yin, T &docSeq) {
char missing_yaml_trait_for_type[sizeof(MissingTrait<T>)]; char missing_yaml_trait_for_type[sizeof(MissingTrait<T>)];
return yin; return yin;
@@ -1037,7 +1035,7 @@ operator>>(Input &yin, T &docSeq) {
// Define non-member operator<< so that Output can stream out document list. // Define non-member operator<< so that Output can stream out document list.
template <typename T> template <typename T>
inline inline
typename llvm::enable_if_c<has_DocumentListTraits<T>::value,Output &>::type typename std::enable_if<has_DocumentListTraits<T>::value, Output &>::type
operator<<(Output &yout, T &docList) { operator<<(Output &yout, T &docList) {
yout.beginDocuments(); yout.beginDocuments();
const size_t count = DocumentListTraits<T>::size(yout, docList); const size_t count = DocumentListTraits<T>::size(yout, docList);
@@ -1054,7 +1052,7 @@ operator<<(Output &yout, T &docList) {
// Define non-member operator<< so that Output can stream out a map. // Define non-member operator<< so that Output can stream out a map.
template <typename T> template <typename T>
inline inline
typename llvm::enable_if_c<has_MappingTraits<T>::value,Output &>::type typename std::enable_if<has_MappingTraits<T>::value, Output &>::type
operator<<(Output &yout, T &map) { operator<<(Output &yout, T &map) {
yout.beginDocuments(); yout.beginDocuments();
if ( yout.preflightDocument(0) ) { if ( yout.preflightDocument(0) ) {
@@ -1068,7 +1066,7 @@ operator<<(Output &yout, T &map) {
// Define non-member operator<< so that Output can stream out a sequence. // Define non-member operator<< so that Output can stream out a sequence.
template <typename T> template <typename T>
inline inline
typename llvm::enable_if_c<has_SequenceTraits<T>::value,Output &>::type typename std::enable_if<has_SequenceTraits<T>::value, Output &>::type
operator<<(Output &yout, T &seq) { operator<<(Output &yout, T &seq) {
yout.beginDocuments(); yout.beginDocuments();
if ( yout.preflightDocument(0) ) { if ( yout.preflightDocument(0) ) {
@@ -1082,7 +1080,7 @@ operator<<(Output &yout, T &seq) {
// Provide better error message about types missing a trait specialization // Provide better error message about types missing a trait specialization
template <typename T> template <typename T>
inline inline
typename llvm::enable_if_c<missingTraits<T>::value,Output &>::type typename std::enable_if<missingTraits<T>::value, Output &>::type
operator<<(Output &yout, T &seq) { operator<<(Output &yout, T &seq) {
char missing_yaml_trait_for_type[sizeof(MissingTrait<T>)]; char missing_yaml_trait_for_type[sizeof(MissingTrait<T>)];
return yout; return yout;

View File

@@ -48,10 +48,10 @@ const error_category& generic_category();
const error_category& system_category(); const error_category& system_category();
template <class T> struct is_error_code_enum template <class T> struct is_error_code_enum
: public false_type {}; : public std::false_type {};
template <class T> struct is_error_condition_enum template <class T> struct is_error_condition_enum
: public false_type {}; : public std::false_type {};
class error_code class error_code
{ {
@@ -203,7 +203,7 @@ enum class errc
wrong_protocol_type // EPROTOTYPE wrong_protocol_type // EPROTOTYPE
}; };
template <> struct is_error_condition_enum<errc> : true_type { } template <> struct is_error_condition_enum<errc> : std::true_type { }
error_code make_error_code(errc e); error_code make_error_code(errc e);
error_condition make_error_condition(errc e); error_condition make_error_condition(errc e);
@@ -225,7 +225,6 @@ template <> struct hash<std::error_code>;
*/ */
#include "llvm/Config/llvm-config.h" #include "llvm/Config/llvm-config.h"
#include "llvm/Support/type_traits.h"
#include <cerrno> #include <cerrno>
#include <string> #include <string>
@@ -474,11 +473,11 @@ namespace llvm {
// is_error_code_enum // is_error_code_enum
template <class Tp> struct is_error_code_enum : public false_type {}; template <class Tp> struct is_error_code_enum : public std::false_type {};
// is_error_condition_enum // is_error_condition_enum
template <class Tp> struct is_error_condition_enum : public false_type {}; template <class Tp> struct is_error_condition_enum : public std::false_type {};
// Some error codes are not present on all platforms, so we provide equivalents // Some error codes are not present on all platforms, so we provide equivalents
// for them: // for them:
@@ -613,9 +612,9 @@ enum _ {
operator int() const {return v_;} operator int() const {return v_;}
}; };
template <> struct is_error_condition_enum<errc> : true_type { }; template <> struct is_error_condition_enum<errc> : std::true_type { };
template <> struct is_error_condition_enum<errc::_> : true_type { }; template <> struct is_error_condition_enum<errc::_> : std::true_type { };
class error_condition; class error_condition;
class error_code; class error_code;
@@ -675,7 +674,7 @@ public:
: _val_(_val), _cat_(&_cat) {} : _val_(_val), _cat_(&_cat) {}
template <class E> template <class E>
error_condition(E _e, typename enable_if_c< error_condition(E _e, typename std::enable_if<
is_error_condition_enum<E>::value is_error_condition_enum<E>::value
>::type* = 0) >::type* = 0)
{*this = make_error_condition(_e);} {*this = make_error_condition(_e);}
@@ -686,13 +685,12 @@ public:
} }
template <class E> template <class E>
typename enable_if_c typename std::enable_if<is_error_condition_enum<E>::value,
< error_condition &>::type
is_error_condition_enum<E>::value, operator=(E _e) {
error_condition& *this = make_error_condition(_e);
>::type return *this;
operator=(E _e) }
{*this = make_error_condition(_e); return *this;}
void clear() { void clear() {
_val_ = 0; _val_ = 0;
@@ -737,7 +735,7 @@ public:
: _val_(_val), _cat_(&_cat) {} : _val_(_val), _cat_(&_cat) {}
template <class E> template <class E>
error_code(E _e, typename enable_if_c< error_code(E _e, typename std::enable_if<
is_error_code_enum<E>::value is_error_code_enum<E>::value
>::type* = 0) { >::type* = 0) {
*this = make_error_code(_e); *this = make_error_code(_e);
@@ -749,13 +747,11 @@ public:
} }
template <class E> template <class E>
typename enable_if_c typename std::enable_if<is_error_code_enum<E>::value, error_code &>::type
< operator=(E _e) {
is_error_code_enum<E>::value, *this = make_error_code(_e);
error_code& return *this;
>::type }
operator=(E _e)
{*this = make_error_code(_e); return *this;}
void clear() { void clear() {
_val_ = 0; _val_ = 0;
@@ -892,9 +888,9 @@ enum _ {
}; };
template <> struct is_error_code_enum<windows_error> : true_type { }; template <> struct is_error_code_enum<windows_error> : std::true_type { };
template <> struct is_error_code_enum<windows_error::_> : true_type { }; template <> struct is_error_code_enum<windows_error::_> : std::true_type { };
inline error_code make_error_code(windows_error e) { inline error_code make_error_code(windows_error e) {
return error_code(static_cast<int>(e), system_category()); return error_code(static_cast<int>(e), system_category());

View File

@@ -41,7 +41,7 @@ struct NonPOD {
namespace hashing { namespace hashing {
namespace detail { namespace detail {
template <> struct is_hashable_data<LargeTestInteger> : true_type {}; template <> struct is_hashable_data<LargeTestInteger> : std::true_type {};
} // namespace detail } // namespace detail
} // namespace hashing } // namespace hashing

View File

@@ -36,7 +36,7 @@ template <typename VectorT>
class TinyPtrVectorTest : public testing::Test { class TinyPtrVectorTest : public testing::Test {
protected: protected:
typedef typename VectorT::value_type PtrT; typedef typename VectorT::value_type PtrT;
typedef typename remove_pointer<PtrT>::type ValueT; typedef typename std::remove_pointer<PtrT>::type ValueT;
VectorT V; VectorT V;
VectorT V2; VectorT V2;

View File

@@ -77,12 +77,16 @@ using namespace llvm;
// Test the peculiar behavior of Use in simplify_type. // Test the peculiar behavior of Use in simplify_type.
int Check1[is_same<simplify_type<Use>::SimpleType, Value *>::value ? 1 : -1]; static_assert(std::is_same<simplify_type<Use>::SimpleType, Value *>::value,
int Check2[is_same<simplify_type<Use *>::SimpleType, Value *>::value ? 1 : -1]; "Use doesn't simplify correctly!");
static_assert(std::is_same<simplify_type<Use *>::SimpleType, Value *>::value,
"Use doesn't simplify correctly!");
// Test that a regular class behaves as expected. // Test that a regular class behaves as expected.
int Check3[is_same<simplify_type<foo>::SimpleType, int>::value ? 1 : -1]; static_assert(std::is_same<simplify_type<foo>::SimpleType, int>::value,
int Check4[is_same<simplify_type<foo *>::SimpleType, foo *>::value ? 1 : -1]; "Unexpected simplify_type result!");
static_assert(std::is_same<simplify_type<foo *>::SimpleType, foo *>::value,
"Unexpected simplify_type result!");
namespace { namespace {