1279 Commits

Author SHA1 Message Date
Richard Smith
b4aa97130b Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr from
<string.h> and wcschr, wcspbrk, wcsrchr, wmemchr, and wcsstr from <wchar.h> to
provide a const-correct overload set even when the underlying C library does
not.

This change adds a new macro, _LIBCPP_PREFERRED_OVERLOAD, which (if defined)
specifies that a given overload is a better match than an otherwise equally
good function declaration without the overload. This is implemented in modern
versions of Clang via __attribute__((enable_if)), and not elsewhere.

We use this new macro to define overloads in the global namespace for these
functions that displace the overloads provided by the C library, unless we
believe the C library is already providing the correct signatures.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@260337 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-10 00:59:02 +00:00
Saleem Abdulrasool
f3adaaf5d7 Use the reserved spellings for attributes
Change the no_sanitize attribute to use the reserved spelling.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@260195 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-09 04:05:37 +00:00
Eric Fiselier
398588caf7 Revert r260012 due to __gnu_cxx::hash_map breakage
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@260172 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-08 23:47:13 +00:00
Eric Fiselier
cf108ebe8c Cleanup node-type handling in the unordered containers
This patch is the first in a series of patches that's meant to better
support unordered_map. unordered_map has a special "value_type" that
differs from pair<const Key, Value>. In order to meet the EmplaceConstructible
and CopyInsertable requirements we need to teach __hash_table about this
special value_type.

This patch creates a "__hash_node_types" traits class that contains
all of the typedefs needed by the unordered containers and it's iterators.
These typedefs include ones for each node type and  node pointer type,
as well as special typedefs for "unordered_map"'s value type.

As a result of this change all of the unordered containers now all support
incomplete types.

As a drive-by fix I changed the difference_type in __hash_table to always
be ptrdiff_t. There is a corresponding change to size_type but it cannot
take affect until an ABI break.

This patch will be followed up shortly with fixes for various unordered_map
fixes.



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@260012 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-07 00:36:33 +00:00
Duncan P. N. Exon Smith
e784f5770f re.results.form: Format out-of-range subexpression references as null
Rather than crashing in match_results::format() when a reference to a
marked subexpression is out of range, format the subexpression as empty
(i.e., replace it with an empty string).  Note that
match_results::operator[]() has a range-check and returns a null match
in this case, so this just re-uses that logic.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@259682 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-03 19:30:20 +00:00
Marshall Clow
b8d4b4c26d Left a file out of r259014
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@259015 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-28 04:15:35 +00:00
Eric Fiselier
c778a6a924 Fix broken commit r258888. I missed adding two pointer conversions
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258893 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-27 00:49:20 +00:00
Eric Fiselier
de637db263 [libcxx] Fix undefined behavior in forward_list
Summary:
This patch is similar to the <list> fix but it has a few differences. This patch doesn't use a `__link_pointer` typedef because we don't need to change the linked list pointers because `forward_list` never stores a  `__forward_begin_node` in the linked list itself. 

The issue with `forward_list` is that the iterators store pointers to `__forward_list_node` and not `__forward_begin_node`. This is incorrect because `before_begin()` and `cbefore_begin()` return iterators that point to a `__forward_begin_node`. This means we incorrectly downcast the `__forward_begin_node` pointer to a `__node_pointer`. This downcast itself is sometimes UB but it cannot be safely removed until ABI v2. The more common cause of UB is when we deference the downcast pointer. (for example `__ptr_->__next_`). This can be fixed without an ABI break by upcasting `__ptr_` before accessing it.

The fix is as follows:

1. Introduce a `__iter_node_pointer` typedef that works  similar to `__link_pointer` in the last patch. In ABI v2 it is always a typedef for `__begin_node_pointer`.
2. Change the `__before_begin()` method to return the correct pointer type (`__begin_node_pointer`),
    Previously it incorrectly downcasted  the  `__forward_begin_node` to a `__node_pointer`  so it could be used to constructor the iterator types.
3. Change `__forward_list_iterator` and `__forward_list_const_iterator`  in the following way:
    1. Change `__node_pointer __ptr_;` member to  have the `__iter_node_pointer` type instead. 
    2. Add additional private constructors that accept `__begin_node_pointer` in addition to `__node_pointer` and then correctly cast them to the stored `__iter_node_pointer` type. 
    3. Add  `__get_begin()` and `__get_node_unchecked()` accessor methods that correctly cast `__ptr_` to the expected pointer type. `__get_begin()` is always safe to use and should be 
       preferred. `__get_node_unchecked()` can only be used on a deferencible iterator.
4. Replace direct access to `__forward_list_iterator::__ptr_`  with the safe accessor methods.
  


Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258888 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-27 00:11:54 +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
Marshall Clow
73de880a44 Implement LWG#2385; remove the allocator-aware std::function::assign call. It was useless, and didn't actually *do anything* with the allocator. Now it's gone. On the off chance that someone is mistakenly calling it, it's only gone in C++1z
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258697 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-25 17:29:55 +00:00
Duncan P. N. Exon Smith
005e38f9fb Revert "unordered_map: Reuse insert logic in emplace when possible, NFC"
This reverts commit r258575.  EricWF sent me an email (no link since it
was off-list) requesting to review this pre-commit instead of
post-commit.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258625 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-23 15:12:47 +00:00
Duncan P. N. Exon Smith
9f745c8696 unordered_map: Reuse insert logic in emplace when possible, NFC
An upcoming commit will add an optimization to insert() that avoids
unnecessary mallocs when we can safely extract the key type.  This
commit shares code between emplace() and insert():
- if emplace() is given a single argument, and
- value_type is constructible from that argument
so that we have a single code path for the two.

I also updated the debug version of emplace_hint() to defer to
emplace(), like the non-debug version does.

In both cases, there should be NFC here.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258575 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-22 22:48:02 +00:00
Duncan P. N. Exon Smith
9572235332 unordered: Rename __construct_node_hash() to allow forwarding, NFC
Rename the version of __construct_node() that takes a hash as an
argument to __construct_node_hash(), and use perfect-forwarding when
Rvalue references are available.  The primary motivation is to allow
other types through, since unordered_map's value_type is different from
__hash_table's value_type -- a follow-up will take advantage of this --
but the rename is general "goodness".

There should be no functionality change here (aside from enabling the
follow-up).

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258511 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-22 18:27:26 +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
685cdcaf9f Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed as http://reviews.llvm.org/D16262
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258107 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-19 00:50:37 +00:00
Jonathan Roelofs
90a7bf9194 Tame a -Wunknown-attributes warning
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@257707 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 23:27:08 +00:00
Marshall Clow
df9db31c27 Fix PR#25973 : 'basic_string::assign(InputIt, InputIt) doesn't provide the strong exception safety guarantee'. This turned out to be a pervasive problem in <string>, which required a fair amount of rework. Add in an optimization for when iterators provide noexcept increment/comparison/assignment/dereference (which covers many of the iterators in libc++). Reviewed as http://reviews.llvm.org/D15862
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@257682 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 21:54:34 +00:00
Hans Wennborg
b27535c0c3 Update version to 3.9
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@257629 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 17:33:21 +00:00
Dan Gohman
2afbf71fdd [WebAssembly] Set std::numeric_limits's traps field for WebAssembly.
WebAssembly's integer division instruction traps on division by zero; set the
traps field of integral std::numeric_limits to true.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@257612 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-13 16:32:00 +00:00
Marshall Clow
040a0340bf Put the definition of _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK in the right place.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@257422 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-12 00:38:04 +00:00
Marshall Clow
7a3731f82b Preemptively disable unsigned integer sanitization in 32 and 64 bit versions of __murmur2_or_cityhash. This lets people use the unsigned integer overflow checker in UBSAN w/o getting hits from libc++'s hash code (where the unsigned integer overflow is legal and deliberate)> Patch by @danielaustin. Reviewed as: http://reviews.llvm.org/D15973
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@257368 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-11 19:27:10 +00:00
Evgeniy Stepanov
4c7ee806f5 Revert "Remove visibility attributes from out-of-class method definitions in iostreams."
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@257193 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-08 19:21:02 +00:00
Marshall Clow
3426a86039 First half of LWG#2354: 'Unnecessary copying when inserting into maps with braced-init syntax'
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@256859 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-05 19:32:41 +00:00
Eric Fiselier
8e7bd4f7af Remove unsafe "__as_link()" cast member function.
"__as_link()" can only be used safely on "__list_node" objects. This patch
moves the "__as_link()" member function from "__list_node_base" to "__list_node"
so it cannot be used incorrectly.

Unsafe downcasts now use a non-member function so we don't defer the type-punned
pointer.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@256727 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-04 03:27:52 +00:00
Eric Fiselier
5cf84e0425 Use __rebind_pointer to avoid #ifdef block
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@256654 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-30 21:52:00 +00:00
Eric Fiselier
5c74b48537 [libcxx] Fix for ALL undefined behavior in <list>.
Summary:
This patch fixes std::list for builtin pointer types in the current ABI version and fixes std::list for all fancy pointer types in the next ABI version. The patch was designed to minimize the amount of code needed to support both ABI configurations. Currently only ~5 lines of code differ.


Reviewers: danalbert, jroelofs, mclow.lists

Subscribers: dexonsmith, awi, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@256652 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-30 20:57:59 +00:00
Eric Fiselier
9bef1ff571 [libcxx] Fix LWG Issue #2367 - Fixing std::tuple and std::pair's default constructors.
Summary: This patch implements the solution for LWG Issue #2367. See http://cplusplus.github.io/LWG/lwg-active.html#2367

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@256325 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-23 08:20:26 +00:00
Eric Fiselier
199bee0ea7 [libcxx] LWG2485: get() should be overloaded for const tuple&&. Patch from K-Ballo.
Review: http://reviews.llvm.org/D14839

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255941 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-18 00:36:55 +00:00
Eric Fiselier
c8f54c2396 Make noexcept specifications on __hash_table definitions match their declarations.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255738 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-16 00:53:04 +00:00
Eric Fiselier
d6a12b3861 Workaround nasty GCC bug that caused testsuite to hang
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255734 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-16 00:35:45 +00:00
Eric Fiselier
0710b55e29 Remove unused _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS macro
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255686 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15 22:19:03 +00:00
Eric Fiselier
a3d6b126d2 [libcxx] Enable noexcept for GCC 4.6 and greater
Summary:
This patch allows GCC 4.6 and above to use `noexcept` as opposed to `throw()`. 

Is it an ABI safe change to suddenly switch on `noexcept`? I imagine it must be because it's disabled in w/ clang in C++03 but not C++11.


Reviewers: danalbert, jroelofs, mclow.lists

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255683 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15 22:16:47 +00:00
Eric Fiselier
6ba21565bd Mark declarations of externally instantiated functions as inline so GCC doesn't complain.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255599 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15 01:41:41 +00:00
Eric Fiselier
e39f4b996e Fix various GCC mis-configurations for newer versions.
This patch goes through and enables C++11 and C++14 features for newer GCC's.
The main changes are:

1. Turn on variable templates. (Uses __cpp_variable_templates)
2. Assert atomic<Tp> is trivially copyable (Uses _GNUC_VER >= 501).
3. Turn on trailing return support for GCC. (Uses _GNUC_VER >= 404)
4. XFAIL void_t test for GCC 5.1 and 5.2. Fixed in GCC 6.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255585 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15 00:32:21 +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
Marshall Clow
b6621c5259 Fix a corner case that involved calling rethrow_if_nested with a type that had a deleted operator&. Added a test to catch this as well. Thanks to Ville for the heads-up.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255517 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-14 18:01:56 +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
Evgeniy Stepanov
9b452384d4 Remove visibility attributes from out-of-class method definitions in iostreams.
No point in pretending that these methods are hidden - they are
actually exported from libc++.so. Extern template declarations make
them part of libc++ ABI.

This patch does not change libc++.so export list (at least on Linux).

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255177 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-09 23:42:30 +00:00
Evgeniy Stepanov
28c02db8d7 Add 3 more missing inline/visibility attributes.
These are the cases when an out-of-class definition of a method is
marked _LIBCPP_INLINE_VISIBILITY, but the in-class declaration is
not. This will start failing when (or if) we switch to
attribute((internal_linkage)).

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255166 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-09 22:32:36 +00:00
Eric Fiselier
76d2446cf4 Use __make_integer_seq builtin for std::make_integer_sequence. Patch by K-ballo.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255162 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-09 22:03:06 +00:00
Marshall Clow
a3866e4c89 Last bit of P0006; mark it as complete
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@254290 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-30 05:39:30 +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
c666b13c85 Missing file from last commit
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@254286 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-30 05:04:48 +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
14ba0ad689 Add static_assert to set/multiset/map/multimap/forward_list/deque that the allocator's value_type match the container's value_type. vector/unordered/list/string already do this. Add tests for all the containers to verify this.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@254119 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-26 01:24:04 +00:00
Vasileios Kalintiris
5e00a713ed Use libcxx's default rune table with the Musl C library.
Summary:
Also, there are no exported character type tables from Musl so we have to
Fallback to the standard functions. This reduces the number of libcxx's
test-suite failures down to ~130 for MIPS. Most of the remaining failures
come from the atomics (due to the lack of 8-byte atomic-ops in MIPS32) and
thread tests.

Reviewers: mclow.lists, EricWF, dalias, jroelofs

Subscribers: tberghammer, danalbert, srhines, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@253972 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-24 10:24:54 +00:00
Marshall Clow
a660757c72 Fix some mistakes in the <utility> and <tuple> synopses. No functional change. Thannks to K-ballo for the patch
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@253593 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-19 19:45:29 +00:00
Marshall Clow
d8717289a6 Fix some mistakes in the <array> synopsis. No functional change. Thanks to K-ballo for the patch
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@253592 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-19 19:41:04 +00:00