Commit Graph

175 Commits

Author SHA1 Message Date
Eric Fiselier
602fe15f55 Make std::is_assignable tolerate references to incomplete types.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276599 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 02:08:55 +00:00
Eric Fiselier
155b681794 Reimplement is_constructible fallback implementation. Fixes PR21574.
The previous implementation relied highly on specializations to handle
special cases. This new implementation lets the compiler do the work when possible.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276084 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 05:01:24 +00:00
Eric Fiselier
45e9a936b6 Allow is_swappable to SFINAE on deleted/ambiguous swap functions
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@275094 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11 19:57:13 +00:00
Eric Fiselier
14273e8a56 Cleanup superfluous std:: qualifiers in <type_traits>
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@269998 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 23:09:24 +00:00
Eric Fiselier
7995c48d7f Optimize declval for compile times. Patch from Eric Niebler.
This patch implements the C++11 version of declval without requiring a template
instantiation.

See PR27798 for more information. https://llvm.org/bugs/show_bug.cgi?id=27798


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@269991 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 22:23:46 +00:00
Eric Fiselier
6aec0206da Fix PR27538. Remove __is_convertible specializations for array and function types.
This patch fixes a bunch of bugs in the fallback implementation of
is_convertible, which is used by GCC. Removing the "__is_convertible"
specializations for array/function types we fallback on the SFINAE test,
which is more correct.

See https://llvm.org/bugs/show_bug.cgi?id=27538


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@268359 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03 04:26:02 +00:00
Eric Fiselier
8f1e73dfd2 Add is_swappable/is_nothrow_swappable traits
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267079 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21 23:38:59 +00:00
Eric Fiselier
566bcb4bad Fix most GCC attribute ignored warnings
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267074 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21 22:54:21 +00:00
Eric Fiselier
8d5cbd7ce2 Add 'is_callable' and 'is_nothrow_callable' traits and cleanup INVOKE.
The primary purpose of this patch is to add the 'is_callable' traits.
Since 'is_nothrow_callable' required making 'INVOKE' conditionally noexcept
I also took this oppertunity to implement a constexpr version of INVOKE.
This fixes 'std::experimental::apply' which required constexpr 'INVOKE support'.

This patch will be followed up with some cleanup. Primarly removing most
of "__member_function_traits" since it's no longer used by INVOKE (in C++11 at least).


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266836 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20 00:14:32 +00:00
Eric Fiselier
134ff65b8f Implement LWG issue 2219 - support reference_wrapper in INVOKE
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266590 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18 06:17:30 +00:00
Eric Fiselier
dc414cd8ca Teach map/unordered_map how to optimize 'emplace(Key, T)'.
In cases where emplace is called with two arguments and the first one
matches the key_type we can Key to check for duplicates before allocating.

This patch expands on work done by dexonsmith@apple.com.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266498 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 00:23:12 +00:00
Eric Fiselier
83c9dc1714 Extract key to avoid preemptive mallocs in insert/emplace in associative containers
Summary: This patch applies Duncan's work on __hash_table to __tree.

Reviewers: mclow.lists, dexonsmith

Subscribers: dexonsmith, cfe-commits

Differential Revision: http://reviews.llvm.org/D18637

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266491 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-15 23:27:27 +00:00
Eric Fiselier
735026e3ee Make std::addressof constexpr in C++17 (Clang only).
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263688 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-17 03:30:56 +00:00
Eric Fiselier
8b15aee1a1 Add __unconstref for future use
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263659 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-16 20:32:07 +00:00
Evgeniy Stepanov
2fe62cded3 Disable CFI checks in std::addressof.
std::addressof may be used on a storage of an object before the start
of its lifetime (see std::allocate_shared for example). CFI flags the
C-style cast as invalid in that case.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263310 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-11 23:50:57 +00:00
Marshall Clow
d812865ec0 Fix __is_referenceable to work with vector types. Fixes PR#26654 and 26656. Thanks to Evgeniy for the reports, and to Eric for the suggestion on how to fix it.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@261581 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-22 22:13:03 +00:00
Eric Fiselier
2960ae20e2 Teach __hash_table how to handle unordered_map's __hash_value_type.
This patch is fairly large and contains a number of changes. The main change
is teaching '__hash_table' how to handle '__hash_value_type'. Unfortunately
this change is a rampant layering violation, but it's required to make
unordered_map conforming without re-writing all of __hash_table.
After this change 'unordered_map' can delegate to '__hash_table' in almost all cases.

The major changes found in this patch are:

  * Teach __hash_table to differentiate between the true container value type
    and the node value type by introducing the "__container_value_type" and
    "__node_value_type" typedefs. In the case of unordered_map '__container_value_type'
    is 'pair<const Key, Value>' and '__node_value_type' is '__hash_value_type'.
    
  * Switch almost all overloads in '__hash_table' previously taking 'value_type'
    (AKA '__node_value_type) to take  '__container_value_type' instead. Previously
    'pair<K, V>' would be implicitly converted to '__hash_value_type<K, V>' because
    of the function signature.
    
  * Add '__get_key', '__get_value', '__get_ptr', and '__move' static functions to
    '__key_value_types'. These functions allow '__hash_table' to unwrap
    '__node_value_type' objects into '__container_value_type' and its sub-parts.

  * Pass  '__hash_value_type::__value_'  to 'a.construct(p, ...)' instead of
    '__hash_value_type' itself. The C++14 standard requires that 'a.construct()'
    and 'a.destroy()' are only ever instantiated for the containers value type.

  * Remove '__hash_value_type's constructors and destructors. We should never
    construct an instance of this type.
    (TODO this is UB but we already do it in plenty of places).
  
  * Add a generic "try-emplace" function to '__hash_table' called
    '__emplace_unique_key_args(Key const&, Args...)'.

  
The following changes were done as cleanup:

  * Introduce the '_LIBCPP_CXX03_LANG' macro to be used in place of
    '_LIBCPP_HAS_NO_VARIADICS' or '_LIBCPP_HAS_NO_RVALUE_REFERENCE'.
    
  * Cleanup C++11 only overloads that assume an incomplete C++11 implementation.
    For example this patch removes the __construct_node overloads that do
    manual pack expansion.
    
  * Forward 'unordered_map::emplace' to '__hash_table' and remove dead code
    resulting from the change. This includes almost all
    'unordered_map::__construct_node' overloads.


The following changes are planed for future revisions:

  * Fix LWG issue #2469 by delegating 'unordered_map::operator[]' to use
    '__emplace_unique_key_args'.
    
  * Rewrite 'unordered_map::try_emplace' in terms of '__emplace_unique_key_args'.
  
  * Optimize '__emplace_unique' to call '__emplace_unique_key_args' when possible.
    This prevent unneeded allocations when inserting duplicate entries.


The additional follow up work needed after this patch:

  * Respect the lifetime rules for '__hash_value_type' by actually constructing it.
  * Make '__insert_multi' act similar to '__insert_unique' for objects of type
    'T&' and 'T const &&' with 'T = __container_value_type'.
  
  

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@260513 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-11 11:59:44 +00:00
Eric Fiselier
949215c589 Remove dead code missed in r258852.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258855 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26 20:31:01 +00:00
Eric Fiselier
e01f946792 Fix PR26103 - Error calling is_convertible with incomplete type. Patch from Michael Daniels.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258852 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26 20:24:30 +00:00
Eric Fiselier
219d4efd34 Add __uncvref type for use in later patches
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258491 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-22 06:25:47 +00:00
Marshall Clow
7a7960ff7f Implement LWG#2101 'Some transformation types can produce impossible types' Introduced a new (internal) type trait '__is_referenceable' with tests. Use that trait in add_lvalue_reference, add_rvalue_reference and add_pointer.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258418 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-21 18:22:43 +00:00
Marshall Clow
d18b496f7e Missed this on the previous (255517) commit
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255518 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-14 18:02:23 +00:00
Eric Fiselier
bbca174790 Remove redundant _LIBCPP_ALWAYS_INLINE attribute from __convert_to_integral overloads
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255185 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-10 00:43:37 +00:00
Marshall Clow
ea972908a3 Fix bugs in alignment_of_v, etc. Re-enable the newly added tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@254289 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-30 05:20:00 +00:00
Marshall Clow
a3e7f528a2 Implement more of P0006; Type Traits Variable Templates.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@254283 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-30 04:30:02 +00:00
Marshall Clow
fe99a30bd0 Implement P0013R1: Logical Operator Type Traits. Make a hidden implementation (__and_, __or_, and __not_) so that we can use them elsewhere in non-C++17 code - for example, in the LFTS
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@253215 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-16 15:54:13 +00:00
Marshall Clow
55d741c32e Walter pointed out some missing includes in the tests. Fixing the includes uncovered a couple bugs in the _v type traits. Fixed those, too
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@252612 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-10 15:48:23 +00:00
Marshall Clow
6455d85714 More of P0006R0: type traits variable aliases for C++17.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@252406 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-07 17:44:36 +00:00
Marshall Clow
94611a888b Implement the first part of P0006R0: Adopt Type Traits Variable Templates for C++17. Significantly augment the existing tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@251766 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-01 20:24:59 +00:00
Eric Fiselier
514c831504 Remove possible trailing padding from aligned_storage. Patch from Yiran Wang
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@248309 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 18:37:03 +00:00
Eric Fiselier
65a6f64221 make common_type SFINAE-friendly and support void. Patch from Agustin Berge.
This patch also fixes PR22135. (https://llvm.org/bugs/show_bug.cgi?id=22135)
See the review for more information: http://reviews.llvm.org/D6964


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246977 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-08 00:13:57 +00:00
Marshall Clow
6d9da5891f Remove unused code. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246445 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-31 14:43:41 +00:00
Eric Fiselier
cae4caba73 Move __lazy_* metafunctions to type traits and add tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246408 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-31 03:50:31 +00:00
Joerg Sonnenberger
ba865ff66b Protect template argument from user interference.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@244462 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-10 16:58:04 +00:00
Nick Lewycky
e1be30b7e1 Fix typo in unused variable name.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243586 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-29 22:38:23 +00:00
Eric Fiselier
12c6d9cd93 [libcxx] Get is_*_destructible tests passing in C++03.
Summary: This patch adds proper guards to the is_destructible tests depending on the standard version so that they pass in c++03.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D10047

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242612 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-18 16:43:58 +00:00
Eric Fiselier
4983580dc5 Cleanup result_of tests and fix issues with the C++03 result_of.
The two main fixes this patch contains are:
- use __identity_t instead of common_type. common_type was used as an
  identity metafunction but the decay resulted in incorrect results.
- Pointers to free functions were not counted as functions. Remove the pointer
  before checking if a type is a function.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@239668 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-13 08:25:24 +00:00
Eric Fiselier
3a0e430cd4 [libcxx] Fix detection of __is_final.
Summary: Currently we only enable the use of __is_final(...) with Clang. GCC also provides __is_final(...) since 4.7 in all standard modes. This patch creates the macro _LIBCPP_HAS_IS_FINAL to note the availability of `__is_final`.

Reviewers: danalbert, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D8795

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@239664 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-13 07:08:02 +00:00
Eric Fiselier
b7fc49f828 Make __void_t unary and always provide it.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@239655 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-13 02:36:07 +00:00
Eric Fiselier
eeeada1c77 Enable __is_trivially* intrinsics for GCC 5.1
Until GCC 5.1 the __is_trivially* intrinsics were not provided. Enable use of
the builtins for GCC 5.1.

Also enable Reference qualified member functions for GCC 4.9 and greater.

This patch also defines _GNUC_VER to 0 when __GNUC__ is not defined because
libc++ assumes _GNUC_VER is always defined.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@239653 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-13 02:18:44 +00:00
Eric Fiselier
724b5ab350 Refactor is_member_function_pointer to use is_function and not __member_function_traits.
Replacing the dependancy on __member_function_traits with is_function allows
is_member_function_pointer to work more often. In particular it allows it to
work when we don't have variadic templates but the function has an arity > 3.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@239649 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-13 00:33:13 +00:00
Marshall Clow
e62560a9b6 Add support for N4389 - std::bool_constant
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@237636 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-18 23:21:06 +00:00
Eric Fiselier
c254b36c29 Remove constexpr support for std::apply because it introduces regressions.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@235274 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-19 15:32:52 +00:00
Marshall Clow
3a4964aef3 Qualify an internal call in is_assignable to prevent ADL lookup, which would 'complete' an type definition unnecessarily. Thanks to Richard Smith for the report.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@234886 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 13:53:53 +00:00
Eric Fiselier
4bd15469a9 [libcxx] Fix PR22771 - Support access control SFINAE in the library version of is_convertible.
Summary:
Currently the conversion check does not take place in a context where access control SFINAE is applied. This patch changes the context of the test expression so that SFINAE occurs if access control does not permit the conversion.

Related bug: https://llvm.org/bugs/show_bug.cgi?id=22771

Reviewers: mclow.lists, rsmith, dim

Reviewed By: dim

Subscribers: dim, rodrigc, emaste, cfe-commits

Differential Revision: http://reviews.llvm.org/D8461

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@233552 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 15:22:20 +00:00
Eric Fiselier
ffbfbcda66 Create macro to allow testing of is_convertible without the compiler builtin.
Summary: This patch also fixes one test case that failed in the library version of is_convertible.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D8456

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@232764 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 21:11:02 +00:00
Eric Fiselier
13858ee056 [libcxx] Add <experimental/tuple> header for LFTS.
Summary:
This patch adds the `<experimental/tuple>` header (almost) as specified in the latest draft of the library fundamentals TS.

The main changes in this patch are:

1. Added variable template `tuple_size_v`
2. Added function `apply(Func &&, Tuple &&)`.
3. Changed `__invoke` to be `_LIBCPP_CONSTEXPR_AFTER_CXX11`.

The `apply(...)` implementation uses `__invoke` to invoke the given function. `__invoke` already provides the required functionality. Using `__invoke` also allows `apply` to be used on pointers to member function/objects as an extension. In order to facilitate this `__invoke` has to be marked `constexpr`. 



Test Plan:
Each new feature was tested. 

The test cases for `tuple_size_v` are as follows:
1. tuple_size_v.pass.cpp
  - Check `tuple_size_v` on cv qualified tuples, pairs and arrays.
2. tuple_size_v.fail.cpp
  - Test on reference type.
3. tuple_size_v_2.fail.cpp
  - Test on non-tuple
4. tuple_size_v_3.fail.cpp
  - Test on pointer type.

The test cases for tuple.apply are as follows:

1. arg_type.pass.cpp
   - Ensure that ref/pointer/cv qualified types are properly passed.
2. constexpr_types.pass.cpp
   - Ensure constexpr evaluation of apply is possible for `tuple` and `pair`.
3. extended_types.pass.cpp
   - Test apply on function types permitted by extension.
4. large_arity.pass.cpp
   - Test that apply can evaluated on tuples and arrays with large sizes.
5. ref_qualifiers.pass.cpp
   - Test that apply respects ref qualified functions.
6. return_type.pass.cpp
   - Test that apply returns the proper type.
7. types.pass.cpp
   - Test apply on function types as required by LFTS.

Reviewers: mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4512

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@232515 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 18:28:14 +00:00
Eric Fiselier
da1818a08c [libc++] Try and prevent evaluation of is_default_constructible on tuples default constructor if it is not needed.
Summary:
Currently parts of the SFINAE on tuples default constructor always gets evaluated even when the default constructor is never called or instantiated. This can cause a hard compile error when a tuple is created with types that do not have a default constructor. Below is a self contained example using a pair like class. This code will not compile but probably should.

```

#include <type_traits>

template <class T>
struct IllFormedDefaultImp {
    IllFormedDefaultImp(T x) : value(x) {}
    constexpr IllFormedDefaultImp() {}
    T value;
};

typedef IllFormedDefaultImp<int &> IllFormedDefault;

template <class T, class U>
struct pair
{
  template <bool Dummy = true,
    class = typename std::enable_if<
         std::is_default_constructible<T>::value
      && std::is_default_constructible<U>::value
      && Dummy>::type
    >
  constexpr pair() : first(), second() {}

  pair(T const & t, U const & u) : first(t), second(u) {}

  T first;
  U second;
};

int main()
{
  int x = 1;
  IllFormedDefault v(x);
  pair<IllFormedDefault, IllFormedDefault> p(v, v);
}
```

One way to fix this is to use `Dummy` in a more involved way in the constructor SFINAE. The following patch fixes these sorts of hard compile errors for tuple.


Reviewers: mclow.lists, rsmith, K-ballo, EricWF

Reviewed By: EricWF

Subscribers: ldionne, cfe-commits

Differential Revision: http://reviews.llvm.org/D7569

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@230120 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-21 02:30:41 +00:00
Eric Fiselier
89465dce7c [libc++] Fix PR20084 - std::is_function<void() const> failed.
Summary:
This patch introduces some black magic to detect const and volatile qualified function types such as `void () const`.

The patch works in the following way:

We first rule out any type that satisfies on of the following. These restrictions are important so that the test below works properly.
* `is_class<_Tp>::value`
* `is_union<_Tp>::value`
* `is_void<_Tp>::value`
* `is_reference<_Tp>::value`
* `__is_nullptr_t<_Tp>::value`


If none of the above is true we perform overload resolution on `__source<_Tp>(0)` to determine the return type.
*  If `_Tp&` is well-formed we select `_Tp& __source(int)`. `_Tp&` is only ill formed for cv void types and cv/ref qualified function types.
* Otherwise we select `__dummy_type __source(...)`. Since we know `_Tp` cannot be void then it must be a function type.


let `R` be the returned from `__source<_Tp>(0)`. 
We perform overload resolution on `__test<_Tp>(R)`.
* If `R` is `__dummy_type` we call `true_type __test(__dummy_type)`.
* if `R` is `_Tp&` and `_Tp&` decays to `_Tp*` we call `true_type __test(_Tp*)`.  Only references to function types decay to a pointer of the same type.
* In all other cases we call `false_type __test(...)`. 

`__source<_Tp>(0)` will try and form `_Tp&`  in the return type. if `_Tp&` is not well formed the return type of `__source<_Tp>(0)` will be dummy type. `_Tp&` is only ill-formed for cv/ref qualified function types (and void which is dealt with elsewhere).


This fixes PR20084 - http://llvm.org/bugs/show_bug.cgi?id=20084

Reviewers: rsmith, K-ballo, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D7573

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@229696 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-18 16:31:46 +00:00
Eric Fiselier
31cb7fe75e [libcxx] Properly convert the count arguments to the *_n algorithms before use.
Summary:
The requirement on the `Size` type passed to *_n algorithms is that it is convertible to an integral type. This means we can't use a variable of type `Size` directly. Instead we need to convert it to an integral type first.  The problem is finding out what integral type to convert it to.  `__convert_to_integral` figures out what integral type to convert it to and performs the conversion, It also promotes the resulting integral type so that it is at least as big as an integer. `__convert_to_integral` also has a special case for converting enums. This should only work on non-scoped enumerations because it does not apply an explicit conversion from the enum to its underlying type.



Reviewers: chandlerc, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D7449

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@228704 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-10 16:46:42 +00:00