Commit Graph

1879 Commits

Author SHA1 Message Date
Eric Fiselier 2a1bfa98d1 [libcxx] Remove unexpected handlers in C++17
Summary:
This patch implements [P0003R5](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0003r5.html) which removes exception specifications from C++17.

The only changes to the library are removing `set_unexpected`, `get_unexpected`, `unexpected`, and `unexpected_handler`. These functions can be re-enabled in C++17 using `_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS`.

@mclow.lists what do you think about removing stuff is this way?

Reviewers: mclow.lists

Reviewed By: mclow.lists

Subscribers: mclow.lists, cfe-commits

Differential Revision: https://reviews.llvm.org/D28172

llvm-svn: 295406
2017-02-17 03:25:08 +00:00
Eric Fiselier 63895ca6e7 Mark a couple for basic_string member templates as inline. no ABI change this time.
llvm-svn: 295403
2017-02-17 02:31:56 +00:00
Eric Fiselier de547c6a23 Remove more basic_string member function templates from the dylib exports
llvm-svn: 295398
2017-02-17 01:53:16 +00:00
Eric Fiselier dd3ba794ef [libc++] Fix PR 31938 - std::basic_string constructors use non-deductible parameter types.
Summary:
This patch fixes http://llvm.org/PR31938. The description below is copy/pasted from the bug:

The standard says:

template<class charT, class traits = char_traits<charT>,
         class Allocator = allocator<charT>>
class basic_string {
  using value_type = typename traits::char_type;
  // ...
  basic_string(const charT* s, const Allocator& a = Allocator());
};

libc++ actually chooses to declare the constructor as

  basic_string(const value_type* s, const Allocator& a = Allocator());

The implicit deduction guides from class template argument deduction make what was previously an implementation detail visible:

std::basic_string s = "foo"; // error, can't deduce charT.

The constructor in question is in the libc++ DSO, but fortunately it looks like fixing this will not result in an ABI break.


@rsmith How does this look? I did more than just the constructors mentioned in the PR, but IDK how far to take it.


Reviewers: mclow.lists, rsmith

Reviewed By: rsmith

Subscribers: cfe-commits, rsmith

Differential Revision: https://reviews.llvm.org/D29863

llvm-svn: 295393
2017-02-17 01:17:10 +00:00
Saleem Abdulrasool 3d99648f00 math: correct the MSVCRT condition
Fixes a number of tests in the testsuite on Windows.

llvm-svn: 295330
2017-02-16 15:47:50 +00:00
Saleem Abdulrasool 305b4f2ba9 threading_support: make __thread_sleep_for be alertable
On Windows, we were using `Sleep` which is not alertable.  This means
that if the thread was used for a user APC or WinProc handling and
thread::sleep was used, we could potentially dead lock.  Use `SleepEx`
with an alertable sleep, resuming until the time has expired if we are
awoken early.

llvm-svn: 295329
2017-02-16 15:47:45 +00:00
Saleem Abdulrasool 3444e9fa15 config: disable thread safety analysis on COFF
clang cannot properly handle __declspec and __attribute__ on classes
right now.  This prevents the shared_mutex tests from working.  Disable
the use of the annotation on COFF targets.

llvm-svn: 294958
2017-02-13 15:26:51 +00:00
Saleem Abdulrasool 8a5789ebd1 math: actually pull the declarations/overloads into std
The previous changes missed the change to include/cmath.  These changes
allow some of the rand.distribution tests to pass on Windows.

llvm-svn: 294957
2017-02-13 15:26:50 +00:00
Saleem Abdulrasool ce5ce02604 math: follow up to SVN r294902
Pull in the math functions from ucrt 14+ after auditing the library.  It
seems that they are now complete for C99 math.  Fixes more windows
tests!

llvm-svn: 294918
2017-02-12 21:42:37 +00:00
Saleem Abdulrasool 2fe5658d9a math: pull more C functions from std
The newer ucrt version provides the gamma meth routines.  Includede them
when building the library.

llvm-svn: 294902
2017-02-12 17:37:45 +00:00
Saleem Abdulrasool a24d7dff09 cmath: adjust math forwards for Windows
The newer versions of ucrt have the math routines.  Use the CRT version
to determine if we should include the math routines.  Fixes two tests
for Windows.

llvm-svn: 294899
2017-02-12 16:44:17 +00:00
Marshall Clow 58fc1b50d8 Make lcm/gcd work better in edge cases. Fixes a UBSAN failure.
llvm-svn: 294779
2017-02-10 20:49:08 +00:00
Eric Fiselier d22c9dc422 Recommit "Split exception.cpp and new.cpp implementation into different files for different runtimes."
This recommits r294707 with additional fixes. The main difference is
libc++ now correctly builds without any ABI library.

exception.cpp is a bloody mess. It's full of confusing #ifdef branches for
each different ABI library we support, and it's getting unmaintainable.

This patch breaks down exception.cpp into multiple different header files,
roughly one per implementation. Additionally it moves the definitions of
exceptions in new.cpp into the correct implementation header.

This patch also removes an unmaintained libc++abi configuration.
This configuration may still be used by Apple internally but there
are no other possible users. If it turns out that Apple still uses
this configuration internally I will re-add it in a later commit.
See http://llvm.org/PR31904.

llvm-svn: 294730
2017-02-10 08:57:35 +00:00
Eric Fiselier 8dcdeaeb35 Revert "Split exception.cpp and new.cpp implementation into different files for different runtimes."
The compiler-rt CMake configuration needs some tweaking before this can land.

llvm-svn: 294727
2017-02-10 07:43:08 +00:00
Eric Fiselier def60acdf5 Split exception.cpp and new.cpp implementation into different files for different runtimes.
exception.cpp is a bloody mess. It's full of confusing #ifdef branches for
each different ABI library we support, and it's getting unmaintainable.

This patch breaks down exception.cpp into multiple different header files,
roughly one per implementation. Additionally it moves the definitions of
exceptions in new.cpp into the correct implementation header.

This patch also removes an unmaintained libc++abi configuration.
This configuration may still be used by Apple internally but there
are no other possible users. If it turns out that Apple still uses
this configuration internally I will re-add it in a later commit.
See http://llvm.org/PR31904.

llvm-svn: 294707
2017-02-10 04:25:33 +00:00
Saleem Abdulrasool 9e08f9a9ad __threading_support: fix windows build
The build was broken as there was no overload for long and
std::chrono::nanoseconds.  Add an explicit conversion to use the
operator+.

llvm-svn: 294698
2017-02-10 02:49:52 +00:00
Mehdi Amini 48b4b04700 Fully qualify (preprend ::) calls to math functions from libc
Summary:
This can cause a compile failure in cases like:

double log(double);
namespace foo {
  namespace log {}
}
using namespace foo;
void bar(int i) {
  log((double)i);
}

Reviewers: EricWF, mclow.lists

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D29804

llvm-svn: 294696
2017-02-10 02:44:23 +00:00
David L. Jones 4b22736222 Check for musl-libc's max_align_t in addition to other variants.
Summary:
Libcxx will define its own max_align_t when it is not available. However, the
availability checks today only check for Clang's definition and GCC's
definition. In particular, it does not check for musl's definition, which is the
same as GCC's but guarded with a different macro.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: chandlerc, cfe-commits

Differential Revision: https://reviews.llvm.org/D28478

llvm-svn: 294683
2017-02-10 01:27:42 +00:00
Eric Fiselier a18ef6f1f9 Fix PR31916 - std::visit rejects visitors accepting lvalue arguments
A static assertion was misfiring since it checked
is_callable<Visitor, decltype(__variant_alt<T>.value)>. However
the decltype expression doesn't capture the value category as
required. This patch applies extra braces to decltype to fix
that.

llvm-svn: 294612
2017-02-09 19:01:22 +00:00
Joerg Sonnenberger 9e8a082db4 Use protected name for the prototype arguments.
llvm-svn: 294585
2017-02-09 14:12:29 +00:00
Asiri Rathnayake 54a987e1f1 Threading support: externalize sleep_for() function.
Different platforms implement the wait/sleep functions in difrerent ways.
It makes sense to externalize this into the threading API.

Differential revision: https://reviews.llvm.org/D29630

Reviewers: EricWF, joerg
llvm-svn: 294573
2017-02-09 09:31:41 +00:00
Eric Fiselier d35528b3e7 Add missing include in <numeric>
llvm-svn: 294393
2017-02-08 00:14:13 +00:00
Eric Fiselier 4cdd915fda Prevent UBSAN from generating unsigned overflow diagnostics in the hashing internals
llvm-svn: 294391
2017-02-08 00:10:10 +00:00
Saleem Abdulrasool bcc85cbcde Refer to _LIBCPP_MSVC macro where applicable
Replace preprocess conditions of defined(_MSC_VER) &&
!defined(__clang__) with defined(_LIBCPP_MSVC).  NFC.

Patch by Dave Lee!

llvm-svn: 294171
2017-02-06 05:26:49 +00:00
Eric Fiselier 9af60c4a8b Implement LWG 2773 - std::ignore should be constexpr.
In addition to the PR for LWG 2773 this patch also ensures
that each of std::ignores constructors or assignment operators
are constexpr.

llvm-svn: 294165
2017-02-06 01:25:31 +00:00
Marshall Clow 6a1d078560 Restore the _NOEXCEPT on the dtor of bad_optional_access. Destructors are noexcept by default, so it's not really needed, but the other exception classes have the _NOEXCEPT, and gcc complains if these are missing. I think we should remove them all - but not today.
llvm-svn: 294142
2017-02-05 20:52:32 +00:00
Eric Fiselier 46663d5567 Fix variant build errors with GCC 7
llvm-svn: 294141
2017-02-05 20:36:07 +00:00
Marshall Clow e29b1ed50b Change the base class of std::bad_optional_access. This is a (subtle) ABI change, and is in response to http://http://wg21.link/LWG2806, which I *expect* to be adopted in Kona. I am making this change now in anticipation, and will get it into 4.0, because (a) 4.0 is the first release with std::optional, and (b) I don't want to make an ABI-change later, when the user base should be significantly larger. Note that I didn't change std::experimental::bad_optional_access, because that's still specified to derive from std::logic_error.
llvm-svn: 294133
2017-02-05 20:06:38 +00:00
Eric Fiselier e49cdfbeea Recommit [libcxx] Never use <cassert> within libc++
It is my opinion that libc++ should never use `<cassert>`, including in the `dylib`.
This patch remove all uses of `assert` from within libc++ and replaces most of them with `_LIBCPP_ASSERT` instead.

Additionally this patch turn `LIBCXX_ENABLE_ASSERTIONS`  off by default,
because the standard library should not be aborting user programs unless explicitly asked to.

llvm-svn: 294107
2017-02-04 23:22:28 +00:00
Eric Fiselier 5ddaeb888d Fix inconsistency in tuple's SFINAE. Patch from Andrey Khalyavin"
llvm-svn: 294106
2017-02-04 22:57:01 +00:00
Eric Fiselier dfc9947636 Mark basic_string::assign templates as inline to improve ABI stability.
Visible definitions for basic_string::assign are sometimes emitted in
the dylib depending on the version of LLVM used to compile libc++.
This can cause the check-cxx-abilist target to fail.

This patch attempts marks the basic_string::assign templates as inline
to prevent this. That way the export list is consistent across LLVM
versions.

llvm-svn: 294100
2017-02-04 20:38:35 +00:00
Eric Fiselier fb5c750222 Undefine min/max in __tree
llvm-svn: 294099
2017-02-04 20:27:46 +00:00
Marshall Clow d107be846f Fix PR#31779: basic_string::operator= isn't exception safe.
llvm-svn: 293599
2017-01-31 03:40:52 +00:00
Justin Bogner 8335dd314f Revert "Adorn __call_once_proxy with `inline` and `_LIBCPP_INLINE_VISIBILITY`"
While this change didn't really hurt, it does lead to spurious
warnings about not being able to override weak symbols if you end up
linking objects built with this change to ones built without it.
Furthermore, since __call_once_proxy is called indirectly anyway it
doesn't actually inline ever.

Longer term, it would probably make sense to give this symbol internal
visibility instead.

This reverts r291497

llvm-svn: 293581
2017-01-31 01:26:09 +00:00
Saleem Abdulrasool e4ddaa4427 experimental: remove some extraneous _LIBCPP_FUNC_VIS
These member functions were decorated with `_LIBCPP_FUNC_VIS` when the
class is also decorated with external visibility.  This breaks down when
building for PE/COFF, where the member function cannot be decorated if
it is within a decorated class.  The class attribute will propagate to
the member.  Remove the extraneous decoration.

llvm-svn: 293454
2017-01-30 03:58:26 +00:00
Saleem Abdulrasool a902e7aa94 experimental: tolerate the existence of a `__deref` macro
Microsoft's SAL has a `__deref` macro which results in a compilation
failure when building the filesystem module on Windows.  Rename the
member function internally to avoid the conflict.

llvm-svn: 293449
2017-01-30 00:15:47 +00:00
Saleem Abdulrasool 87996f906a config: prevent the re-definition of a macro
This causes unnecessary warnings when building with `cl`.  Newer
versions of the C standard permit the redefinition of the macro to the
same value (which is the case here), unfortunately, `cl` does not yet
implement this.  Add a check to prevent the redefinition.

llvm-svn: 293439
2017-01-29 18:16:33 +00:00
Dimitry Andric 83dca5c3d1 Disable thread safety analysis for some functions in __thread_support
Many thread-related libc++ test cases fail on FreeBSD, due to the
following -Werror warnings:

    In file included from test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp:17:
    In file included from include/thread:97:
    In file included from include/__mutex_base:17:
    include/__threading_support:222:1: error: mutex '__m' is still held at the end of function [-Werror,-Wthread-safety-analysis]
    }
    ^
    include/__threading_support:221:10: note: mutex acquired here
      return pthread_mutex_lock(__m);
             ^
    include/__threading_support:231:10: error: releasing mutex '__m' that was not held [-Werror,-Wthread-safety-analysis]
      return pthread_mutex_unlock(__m);
             ^
    include/__threading_support:242:1: error: mutex '__m' is still held at the end of function [-Werror,-Wthread-safety-analysis]
    }
    ^
    include/__threading_support:241:10: note: mutex acquired here
      return pthread_mutex_lock(__m);
             ^
    include/__threading_support:251:10: error: releasing mutex '__m' that was not held [-Werror,-Wthread-safety-analysis]
      return pthread_mutex_unlock(__m);
             ^
    include/__threading_support:272:10: error: calling function 'pthread_cond_wait' requires holding mutex '__m' exclusively [-Werror,-Wthread-safety-analysis]
      return pthread_cond_wait(__cv, __m);
             ^
    include/__threading_support:278:10: error: calling function 'pthread_cond_timedwait' requires holding mutex '__m' exclusively [-Werror,-Wthread-safety-analysis]
      return pthread_cond_timedwait(__cv, __m, __ts);
             ^
    6 errors generated.

This is because on FreeBSD, the pthread functions have lock annotations.
Since the functions in __thread_support are internal to libc++ only, add
no_thread_safety_analysis attributes to suppress these warnings.

Reviewers: mclow.lists, EricWF, delesley, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: ed, aaron.ballman, joerg, emaste, cfe-commits
Differential Revision: https://reviews.llvm.org/D28520

llvm-svn: 293197
2017-01-26 18:37:18 +00:00
Asiri Rathnayake e246350467 Fix chromium build (libcxx)
Remove the reference to pthread_mach_thread_np() in libcxx headers.

llvm-svn: 293167
2017-01-26 10:40:17 +00:00
Marshall Clow 3a3c09c5dd Use the new __has_feature(cxx_constexpr_string_builtins) for detection of the C-string intrinsics for constexpr support in std::char_traits. Thanks to Richard for the intrisic support.
llvm-svn: 293154
2017-01-26 06:58:29 +00:00
Marshall Clow 071aded6ee Fixed a typo in the synopsis (noecept -> noexcept). Thanks to Kim for the catch
llvm-svn: 293079
2017-01-25 20:14:03 +00:00
Marshall Clow 3cd9e94241 Implement LWG2556: Wide contract for future::share()
llvm-svn: 292992
2017-01-24 23:28:25 +00:00
Marshall Clow 63b560be69 Change the return type of emplace_[front|back] back to void when building with C++14 or before. Resolves PR31680.
llvm-svn: 292990
2017-01-24 23:09:12 +00:00
Marshall Clow e67179bc6c Remove auto_ptr in C++17. Get it back by defining _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
llvm-svn: 292986
2017-01-24 22:22:33 +00:00
Marshall Clow 0d1b5ce4f9 Implement LWG2733: [fund.ts.v2] gcd / lcm and bool. We already did tbis for C++17, so replicate the changes in experimental.
llvm-svn: 292962
2017-01-24 18:15:48 +00:00
Eric Fiselier f9e7bf3a43 Revert "[libcxx] Never use <cassert> within libc++"
This reverts commit r292883. Unfortunately <string_view> uses
_LIBCPP_ASSERT in a way which is not compatible with the C++11 dylib
build. I'll investigate more tomorrow.

llvm-svn: 292923
2017-01-24 12:26:01 +00:00
Eric Fiselier d5fd7d7ea1 [libcxx] Never use <cassert> within libc++
Summary:
It is my opinion that libc++ should never use `<cassert>`, including in the `dylib`. This patch remove all uses of `assert` from within libc++ and replaces most of them with `_LIBCPP_ASSERT` instead.

Additionally this patch turn `LIBCXX_ENABLE_ASSERTIONS`  off by default, because the standard library should not be aborting user programs unless explicitly asked to.

Reviewers: mclow.lists, compnerd, smeenai

Reviewed By: mclow.lists

Subscribers: mgorny, cfe-commits

Differential Revision: https://reviews.llvm.org/D29063

llvm-svn: 292883
2017-01-24 04:57:33 +00:00
Eric Fiselier 014d9491ff Manually force the use of __decltype in C++03 with Clang 3.4.
<string> uses `decltype` in a way incompatible with `__typeof__`.
This is problematic when compiling <string> with Clang 3.4 because
even though it provides `__decltype` libc++ still used `__typeof__`
because clang 3.4 doesn't provide __is_identifier which libc++
uses to detect __decltype.

This patch manually detects Clang 3.4 and properly configures
for it.

llvm-svn: 292833
2017-01-23 21:41:13 +00:00
Eric Fiselier 5363be7a9c Fix GCC C++03 build by hiding default template argument in C++03
llvm-svn: 292830
2017-01-23 21:24:58 +00:00
Marshall Clow cddeb751a1 Implement LWG#2778: basic_string_view is missing constexpr.
llvm-svn: 292823
2017-01-23 19:53:28 +00:00
Marshall Clow c68c62c97f Fixed a typo in __config that prevented the aligned new/delete tests from passing on Mac OS.
llvm-svn: 292822
2017-01-23 19:51:54 +00:00
Eric Fiselier faa0d10b5a Revert accidentally changes which reverted r292582
llvm-svn: 292717
2017-01-21 14:42:44 +00:00
Eric Fiselier f9127593a9 Implement P0513R0 - "Poisoning the Hash"
Summary:
Exactly what the title says.

This patch also adds a `std::hash<nullptr_t>` specialization in C++17, but it was not added by this paper and I can't find the actual paper that adds it.

See http://wg21.link/P0513R0 for more info.

If there are no comments in the next couple of days I'll commit this

Reviewers: mclow.lists, K-ballo, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28938

llvm-svn: 292684
2017-01-21 00:02:12 +00:00
Eric Fiselier 9114f45ab8 Still expose std::align_val_t in C++17 even if we don't have aligned new/delete.
r292564 disabled the aligned new/delete overloads on platforms without
posix_memalign. Unfortunately that patch also disabled the  align_val_t
definition in C++17 as well.

This patch causes align_val_t to be exposed in C++17 regardless
of if we have the new/delete overloads.

llvm-svn: 292582
2017-01-20 06:27:34 +00:00
Eric Fiselier efea04512c Disable aligned new/delete on Apple platforms without posix_memalign
Summary:
This patch disables the aligned new/delet overloads on Apple platforms without `posix_memalign`. This fixes libc++.dylib build regressions on such platforms.
This fixes http://llvm.org/PR31448.

This patch should also be merged into the 4.0 release branch


Reviewers: mclow.lists, rsmith, dexonsmith, jeremyhu

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28931

llvm-svn: 292564
2017-01-20 01:47:26 +00:00
Eric Fiselier b8c2a52266 Adjust msvc_stdlib_force_include.hpp to handle clang++
Summary: This patch adjusts the newly added `msvc_stdlib_force_include.hpp` so that it also works when used with `clang++`.

Reviewers: STL_MSFT

Reviewed By: STL_MSFT

Differential Revision: https://reviews.llvm.org/D28917

llvm-svn: 292539
2017-01-19 23:48:05 +00:00
Eric Fiselier 337a7c542d Fix filesystem::path assignment from {}
Adding `path::operator=(string_type&&)` made the expression `p = {}`
ambiguous. This path fixes that ambiguity by making the `string&&`
overload a template so it ranks lower during overload resolution.

llvm-svn: 292345
2017-01-18 05:48:55 +00:00
Eric Fiselier 6880885fae Fix type_info's constructor by making it explicit again.
In recent changes type_info's private constructor was
accidentally made implicit. This patch fixes that.

llvm-svn: 292294
2017-01-17 23:41:42 +00:00
Eric Fiselier 38590b3845 Fix std::string assignment ambiguity from braced initializer lists.
When support for `basic_string_view` was added to string it also
added new assignment operators from `basic_string_view`. These caused
ambiguity when assigning from a braced initializer. This patch fixes
that regression by making the basic_string_view assignment operator
rank lower in overload resolution by making it a template.

llvm-svn: 292276
2017-01-17 22:10:32 +00:00
Eric Fiselier 11f6045379 Add ABI option to remove recently inlined __shared_count functions from the library.
In order to allow inlining of previously out-of-line functions without an ABI break
libc++ provides legacy definitions in the dylib that old programs can
continue to use. Unfortunatly Windows link.exe detects this hack and diagnoses the duplicate
definitions.

This patch disable the duplicate definitions on Windows by adding an ABI option
which disables all "legacy out-of-line symbols"

llvm-svn: 292190
2017-01-17 03:16:26 +00:00
Eric Fiselier a480c28b3c Fix DLL build by removing _LIBCPP_FUNC_VIS from member of class marked dllexport
llvm-svn: 292185
2017-01-17 03:05:31 +00:00
Kevin Hu f08de52d77 [Test patch] Inline hot functions in libcxx shared_ptr
Moves hot functions such as atomic add into the memory header file
so that they can be inlined, which brings performance benefits.

Patch by Kevin Hu, Aditya Kumar, Sebastian Pop

Differential Revision: https://reviews.llvm.org/D24991

llvm-svn: 292184
2017-01-17 02:46:33 +00:00
Eric Fiselier b43f17c835 Fix std::tuples EBO when targeting the MSVC ABI.
MSVC/clang-cl doesn't do a full EBO unless __declspec(empty_bases)
is applied to the derived type. This causes certain tuple tests
to fail.

This patch adds the empty_bases attribute to __tuple_impl in order
for tuple to fully provide the EBO.

llvm-svn: 292159
2017-01-16 21:15:08 +00:00
Eric Fiselier fc26379a84 [libc++] Introduce _LIBCPP_EXTERN_VIS to fix __libcpp_debug_function link errors
Summary: On Windows tests that use `_LIBCPP_ASSERT` fail to link because the assertion handler function isn't correctly exported from the libc++ dylib. This patch fixes the dll import/export issues by introducing a new visibility macro `_LIBCPP_EXTERN_VIS` for use on external variables.

Reviewers: compnerd, smeenai, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28728

llvm-svn: 292158
2017-01-16 21:01:00 +00:00
Asiri Rathnayake af762e91b2 [libcxx] Don't assume __libcpp_thread_t is an integral type
We have already refactored the underlying platform thread type into
__libcpp_thread_t, but there are few places in the source where we
still assume it is an integral type.

This patch refactores those points back into the threading API.

Differential revision: https://reviews.llvm.org/D28608

Reviewers: EricWF
llvm-svn: 292107
2017-01-16 12:19:54 +00:00
Michael Park f4770ea983 Added a workaround for a `-fdelayed-template-parsing` bug.
Summary:
There seems to be an additional bug in `-fdelayed-template-parsing`
similar to
http://llvm.org/viewvc/llvm-project?view=revision&revision=236063.

This is a workaround for it for <variant> to compile with `clang-cl` on Windows.

Reviewers: EricWF

Differential Revision: https://reviews.llvm.org/D28734

llvm-svn: 292097
2017-01-16 08:14:25 +00:00
Marshall Clow e78269506f Implement the missing constexpr stuff in <array>. Fixes PR#31645.
llvm-svn: 292091
2017-01-16 03:02:10 +00:00
Eric Fiselier d75a9d253f Attempt two at fixing threading on Windows
Reviewers: compnerd

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28735

llvm-svn: 292027
2017-01-14 20:19:00 +00:00
Eric Fiselier 6f38b6ab6e Fix thread creation on Windows
llvm-svn: 292022
2017-01-14 19:11:07 +00:00
Eric Fiselier 08e1477ccb Fix Windows try_lock implementation
llvm-svn: 292011
2017-01-14 10:27:12 +00:00
Eric Fiselier 1e33f12a7c Use __is_identifier to detect Clang extensions instead of __has_extension.
When -pedantic-errors is specified `__has_extension(<feature>)` is always
false when it would otherwise be true. This causes C++03 <atomic> to break
along with other issues.

This patch avoids the above problem by using __is_identifier(...) instead since
it is not affected by -pedantic-errors. For example instead of checking for
__has_extension(c_atomics) we now check `!__is_identifier(_Atomic)`, which
is only true when _Atomic is not a keyword provided by the compiler.

This patch applies similar changes to the detection logic for __decltype and
__nullptr as well.

Note that it does not apply this change to the C++03
`static_assert` macro since -Wc11-extensions warnings generated by expanding
that macro will appear in user code, and will not be suppressed as part of a
system header.

llvm-svn: 291995
2017-01-14 04:27:58 +00:00
Eric Fiselier a595b7f0f9 Remove unused parameters in C++03
llvm-svn: 291986
2017-01-14 01:33:53 +00:00
Eric Fiselier faf2a81380 Diagnose invalid memory orderings in <atomic>
llvm-svn: 291976
2017-01-13 23:45:39 +00:00
Eric Fiselier 04333f9bda Diagnose non-const-callable hash functions and comparators
llvm-svn: 291969
2017-01-13 22:42:53 +00:00
Eric Fiselier b1e7a12ee8 Add _LIBCPP_DIAGNOSE_WARNING and _LIBCPP_DIAGNOSE_ERROR macros.
Clang recently added a `diagnose_if(cond, msg, type)` attribute
which can be used to generate diagnostics when `cond` is a constant
expression that evaluates to true. Otherwise no attribute has no
effect.

This patch adds _LIBCPP_DIAGNOSE_ERROR/WARNING macros which
use this new attribute. Additionally this patch implements
a diagnostic message when a non-const-callable comparator is
given to a container.

Note: For now the warning version of the diagnostic is useless
within libc++ since warning diagnostics are suppressed by the
system header pragma. I'm going to work on fixing this.

llvm-svn: 291961
2017-01-13 22:02:08 +00:00
Eric Fiselier d066f3af61 Update version to 5.0
llvm-svn: 291928
2017-01-13 18:29:56 +00:00
Eric Fiselier a0f7252b03 Fix merge conflict caused by r291921
llvm-svn: 291925
2017-01-13 18:25:13 +00:00
Eric Fiselier c8bd38a15d Revert "Rework fix for PR19460 - Use explicit bool as an extension instead."
This reverts commit 3a1b90a866b6d5d62a5f37fbfb3a1ee36cc70dd1.

llvm-svn: 291921
2017-01-13 18:03:46 +00:00
Marshall Clow 3d4cc68b8b Add new macro _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR to use in std::char_traits.
This tells whether or not the builtin function __builtin_memcmp is constexpr.
Only defined for clang 4.0 and later, and not true for any shipping version of Apple's clang.

llvm-svn: 291773
2017-01-12 16:25:07 +00:00
Marshall Clow 9087bbee85 disable use of __builtin_memcmp temporarily to get the tests passing again
llvm-svn: 291742
2017-01-12 05:40:58 +00:00
Marshall Clow 05d57faa2e Implement P0426: Constexpr for std::char_traits
llvm-svn: 291741
2017-01-12 04:37:14 +00:00
Marshall Clow 3a6474ecbb Qualify some type names that I thought were fine, but some of the bots don't like.
llvm-svn: 291580
2017-01-10 18:40:01 +00:00
Marshall Clow dc83e7795f Fix up some mismatched SFINAE conditionsin shared_ptr; some used '_Tp*', others used 'element_type *'. Today, they're the same - but soon they won't be. No functional change.
llvm-svn: 291572
2017-01-10 16:59:33 +00:00
Saleem Abdulrasool 4ec493b231 threading_support: delete the critical section
Although the CriticalSection itself doesnt need to be destroyed, there
may be debug data associated with it.  Plug a possible small leak.

llvm-svn: 291536
2017-01-10 04:18:47 +00:00
Justin Bogner 603715c66b Adorn __call_once_proxy with `inline` and `_LIBCPP_INLINE_VISIBILITY`
As per discussion with mclow and EricWF on irc, this is small and
simple enough to deserve being inlined.

llvm-svn: 291497
2017-01-09 23:07:12 +00:00
Marshall Clow 04b9853a97 Swap two lines in __mutex_base. On systems with high clock rates, we could mistakenly return no_timeout when a mutex had timed out if we got a tick between these two lines. Thanks to Brian Cain for the bug report.
llvm-svn: 291492
2017-01-09 22:32:11 +00:00
Dimitry Andric 082fa545cc Move _PairT declaration out of __hash_combine to avoid warning under C++98
Summary:
Some parts of the FreeBSD tree are still compiled with C++98, and until
rL288554 this has always worked fine.  After that, a complaint about the
newly introduced local _PairT is produced:

    /usr/include/c++/v1/memory:3354:27: error: template argument uses local type '_PairT' [-Werror,-Wlocal-type-template-args]
        typedef __scalar_hash<_PairT> _HashT;
                              ^~~~~~
    /usr/include/c++/v1/memory:3284:29: error: template argument uses local type '_PairT' [-Werror,-Wlocal-type-template-args]
        : public unary_function<_Tp, size_t>
                                ^~~
    /usr/include/c++/v1/memory:3356:12: note: in instantiation of template class 'std::__1::__scalar_hash<_PairT, 2>' requested here
        return _HashT()(__p);
               ^

As far as I can see, there should be no problem moving the _PairT
struct to just before the __hash_combine() function, which fixes this
particular warning.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits, emaste

Differential Revision: https://reviews.llvm.org/D28472

llvm-svn: 291476
2017-01-09 20:29:35 +00:00
Marshall Clow 8fd58a6be8 Implement P0403R1 - 'Literal suffixes for basic_string_view'. Requires clang 4.0 (specifically, r290744)
llvm-svn: 291457
2017-01-09 18:07:34 +00:00
Eric Fiselier 5741d86d11 Replace identifiers called `__out` because Windows.h #defines it.
Windows is greedy and it defines the identifier `__out` as a macro.
This patch renames all conflicting libc++ identifiers in order
to correctly work on Windows.

llvm-svn: 291345
2017-01-07 11:27:06 +00:00
Saleem Abdulrasool 6d7d0bec10 provide Win32 native threading
Add an implementation for the Win32 threading model as a backing API for
the internal c++ threading interfaces.  This uses the Fls* family for
the TLS (which has the support for adding termination callbacks),
CRITICAL_SECTIONs for the recursive mutex, and Slim Reader/Writer locks
(SRW locks) for non-recursive mutexes.  These APIs should all be
available on Vista or newer.

llvm-svn: 291333
2017-01-07 03:07:45 +00:00
Eric Fiselier cd71f447b7 [libc++] Tolerate presence of __deallocate macro
Summary:
On Windows the identifier `__deallocate` is defined as a macro by one of the Windows system headers. Previously libc++ worked around this by `#undef __deallocate` and generating a warning. However this causes the WIN32 version of `__threading_support` to always generate a warning on Windows. This is not OK.

This patch renames all usages of `__deallocate` internally as to not conflict with the macro.

Reviewers: mclow.lists, majnemer, rnk, rsmith, smeenai, compnerd

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28426

llvm-svn: 291332
2017-01-07 03:01:24 +00:00
Eric Fiselier 330fe0170f Add _LIBCPP_ABI_[ITANIUM|MICROSOFT] macros.
This patch adds a libc++ configuration macro for the ABI we
are targeting, either Itanium or Microsoft. For now we configure
for the Microsoft ABI when on Windows with a compiler that defines
_MSC_VER. However this is only temporary until Clang implements
builtin macros we can use.

llvm-svn: 291329
2017-01-07 02:43:58 +00:00
Eric Fiselier 72cffa5583 Fix breakage caused when _LIBCPP_HAS_THREAD_API_PTHREAD is manually defined
llvm-svn: 291298
2017-01-06 23:15:16 +00:00
Eric Fiselier 541f9e2830 Add _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] macros.
This patch refactors the compiler detection done in `__config` by creating a
set of `_LIBCPP_COMPILER_<TYPE>` macros. The goal of this patch is to make
it easier to detect what compiler is being used outside of `__config`.

Additionally this patch removes workarounds for GCC in `__bit_reference`. I
tested GCC 4.8 and 4.9 without the workaround and neither seemed to need it
anymore.

llvm-svn: 291286
2017-01-06 21:42:58 +00:00
Eric Fiselier 8f56dedb5f Replace _LIBCPP_HAS_NO_DELETED_FUNCTIONS with _LIBCPP_CXX03_LANG
llvm-svn: 291278
2017-01-06 20:58:25 +00:00
Eric Fiselier 00f6beaed4 [libc++] Cleanup and document <__threading_support>
Summary:
This patch attempts to clean up the macro configuration mess in `<__threading_support>`, specifically the mess involving external threading variants. Additionally this patch adds design documentation for `<__threading_support>` and the configuration macros it uses.

The primary change in this patch is separating the idea of an "external API" provided by `<__external_threading>` and the idea of having an external threading library. Now `_LIBCPP_HAS_THREAD_API_EXTERNAL` means that libc++ should use `<__external_threading>` and that the header is expected to exist.  Additionally the new macro `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` is now used to configure for using an "external library"  with the default threading API.

Reviewers: compnerd, rmaprath

Subscribers: smeenai, cfe-commits, mgorny

Differential Revision: https://reviews.llvm.org/D28316

llvm-svn: 291275
2017-01-06 20:05:40 +00:00
Saleem Abdulrasool 9075622d58 typeinfo: style adjustments for adding MS ABI RTTI
This is motivated by adding a third RTTI scheme to libc++.  Split out
the two forms of the itanium RTTI representation.  This is based on
suggestions from Eric Fiselier.  NFC

llvm-svn: 291174
2017-01-05 21:22:22 +00:00
Saleem Abdulrasool 58a0dcee80 thread_support: split out {,non-}recursive mutex
Split out the recursive and non-recursive mutex.  This split is needed
for platforms which may use differing types for the two mutex (e.g.
Win32 threads).

llvm-svn: 291145
2017-01-05 17:54:45 +00:00
Eric Fiselier cb5cbc8b66 [libcxx] Fix PR31402: map::__find_equal_key has undefined behavior.
Summary:
This patch fixes llvm.org/PR31402 by replacing `map::__find_equal_key` with `__tree::__find_equal`, which has already addressed the same undefined behavior.

Unfortunately I haven't been able to write a test case which causes the UBSAN diagnostic mentioned in the bug report. I can write tests which exercise the UB but for some reason they do not cause UBSAN to fail. Any help writing a test case would be appreciated.


Reviewers: mclow.lists, vsk, EricWF

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28131

llvm-svn: 291087
2017-01-05 06:06:18 +00:00
Eric Fiselier 76a01ea34d Fix PR26961 - Add default constructor to std::pointer_safety struct.
In ABI v1 libc++ implements std::pointer_safety as a class type instead
of an enumeration. However this class type does not provide
a default constructor as it should. This patch adds that default constructor.

llvm-svn: 291059
2017-01-05 01:28:40 +00:00
Eric Fiselier 528600c41f Fix std::pointer_safety type in ABI v2
In the C++ standard `std::pointer_safety` is defined
as a C++11 strongly typed enum. However libc++ currently defines
it as a class type which simulates a C++11 enumeration. This
can be detected in valid C++ code.

This patch introduces an the _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE ABI option.
When defined `std::pointer_safety` is implemented as an enum type.
Unfortunatly this also means it can no longer be provided as an extension
in C++03.

Additionally this patch moves the definition for `get_pointer_safety()`
out of the dylib, and into the headers. New usages of `get_pointer_safety()`
will now use the inline version instead of the dylib version. However in
order to keep the dylib ABI compatible the old definition is explicitly
compiled into it.

llvm-svn: 291046
2017-01-05 01:15:42 +00:00
Eric Fiselier e2f2d1edef [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS
The name _LIBCPP_TYPE_VIS_ONLY is no longer accurate because both
_LIBCPP_TYPE_VIS and _LIBCPP_TYPE_VIS_ONLY expand to
__attribute__((__type_visibility__)) with Clang. The only remaining difference
is that _LIBCPP_TYPE_VIS_ONLY can be applied to templates whereas
_LIBCPP_TYPE_VIS cannot (due to dllimport/dllexport not being allowed on
templates).

This patch renames _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS.

llvm-svn: 291035
2017-01-04 23:56:00 +00:00
Eric Fiselier e5b41f7ccf Fix private inheritance in C++03 tuple_size
llvm-svn: 291032
2017-01-04 23:35:51 +00:00
Marshall Clow dbf7ca9ce6 Implement P0505: 'Wording for GB 50'
llvm-svn: 291028
2017-01-04 23:03:24 +00:00
Eric Fiselier cb0d4df974 [libcxx] Re-implement LWG 2770 again: Fix tuple_size to work with structured bindings
Summary:
This patch attempts to re-implement a fix for LWG 2770, but not the actual specified PR. 

The PR for 2770 specifies tuple_size<T const> as only conditionally providing a `::value` member. However C++17 structured bindings require `tuple_size<T const>` to be complete only if  `tuple_size<T>` is also complete. Therefore this patch implements only provides the specialization `tuple_size<T CV>` iff `tuple_size<T>` is a complete type.

This fixes http://llvm.org/PR31513.

Reviewers: mclow.lists, rsmith, mpark

Subscribers: mpark, cfe-commits

Differential Revision: https://reviews.llvm.org/D28222

llvm-svn: 291019
2017-01-04 22:38:46 +00:00
Marshall Clow 020b623a3b Implement the last bit of P0031: 'A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access' for C++17
llvm-svn: 290976
2017-01-04 17:58:17 +00:00
Saleem Abdulrasool 07b65ed040 config: MSVC 19+ has unicode chars
MSVC 19+ and clang-cl with emulation version >= 19.00 will provide
char{16,32}_t as builtin types.  Adjust the configuration accordingly.

llvm-svn: 290940
2017-01-04 05:49:59 +00:00
Saleem Abdulrasool 86eebc5b65 Refactor bitscan64 check
Introduce a `_LIBCPP_HAS_BITSCAN64` macro to specify if the 64-bit
variant of the bitscan family of APIs is available.  This avoids
duplicating the check in the support header.

llvm-svn: 290924
2017-01-04 01:53:24 +00:00
Saleem Abdulrasool b2826a1ddc clean up use of _WIN32
Replace the use of _WIN32 in libc++. Replace most use with a C runtime
check _LIBCPP_MSVCRT or the new _LIBCPP_WIN32 to indicate that we are
using the Win32 API. Use a new _LIBCPP_WCHAR_IS_UCS2 to indicate that we
are on an environment that has a short wchar_t.

llvm-svn: 290910
2017-01-03 21:53:51 +00:00
Asiri Rathnayake 205d7d3f68 [libcxx] Add build/test support for the externally threaded libc++abi variant
Differential revision: https://reviews.llvm.org/D27576

Reviewers: EricWF
llvm-svn: 290889
2017-01-03 12:59:50 +00:00
Asiri Rathnayake 6cb0d41cc8 [libcxx] Fix testing of the externally-threaded library build
after r290850

Before r290850, building libcxx with -DLIBCXX_HAS_EXTERNAL_THREAD_API=ON had two
uses:
  - Allow platform vendors to plug-in an __external_threading header which
    should take care of the entire threading infrastructure of libcxx

  - Allow testing of an externally-threaded library build; where the thread API
    is declared using pthread data structures, and the implementation of this
    API is provided as a separate library (test/support/external_threads.cpp)
   and linked-in when running the test suite.

r290850 breaks the second use case (pthread data structures are no longer
available). This patch re-stores the ability to build+test an
externally-threaded library variant on a pthread based system.

llvm-svn: 290878
2017-01-03 11:32:31 +00:00
Eric Fiselier a0a61faad1 Simplify CMake target for the __generated_config header
llvm-svn: 290875
2017-01-03 11:18:17 +00:00
Saleem Abdulrasool 833094463c build: remove now unused UNIX_CAT
THe previous change replaced the use of `cat` or `type` with a custom
python script.  Remove the now unused command determining.

llvm-svn: 290856
2017-01-03 04:23:50 +00:00
Eric Fiselier 887894aaef Fix creating __generated_config on Windows
llvm-svn: 290853
2017-01-03 03:55:29 +00:00
Saleem Abdulrasool 790e10f6df threading_support: refactor for Win32 threading
Refactor the header to allow us to implement alternate threading models
with alternate data structures.  Take the opportunity to clang-format
the area.  This will allow us to avoid re-declaring the interfaces for
Win32 threading.  NFC

llvm-svn: 290850
2017-01-03 02:00:31 +00:00
Eric Fiselier 1013fe3c0c Re-implement LWG 2770 - Fix tuple_size with structured bindings.
This patch implements the correct PR for LWG 2770. It also makes the primary
tuple_size template incomplete again which fixes part of llvm.org/PR31513.

llvm-svn: 290846
2017-01-02 23:54:13 +00:00
Eric Fiselier 9877c1e713 Fix use of throw(...) spec with GCC in C++17
llvm-svn: 290845
2017-01-02 23:27:42 +00:00
Eric Fiselier 9aca97d6f9 Introduce _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR ABI option.
Currently libc++ compiles a special version of error_category()
into the dylib. This definition is no longer needed, and doesn't
work on Windows due to dllimport/dllexport semantics.

For those reasons this patch introduces an option to
disable/enable this definition. By default the definition
is provided in ABI v1 except on windows. This patch
also addresses D28210.

llvm-svn: 290840
2017-01-02 22:17:51 +00:00
Eric Fiselier e9735f17e0 Rework fix for PR19460 - Use explicit bool as an extension instead.
In the previous fix I used a PMF type as a semi-safe bool type in C++03.
However immediately after committing I realized clang offered explicit
conversion operators as an extension. This patch removes the old fix and
enables _LIBCPP_EXPLICIT using __has_extension instead.

This change also affects the following other classes, which have
'_LIBCPP_EXPLICIT operator bool()'.

* shared_ptr
* unique_ptr
* error_condition
* basic_ios
* function (already C++11 only)
* istream::sentry
* experimental::string_view.

In all of the above cases I believe it is safe to enable the extension, except
in the experimental::string_view case. There seem to be some Clang bugs
affecting the experimental::string_view conversion to std::basic_string. To
work around that I manually disabled _LIBCPP_EXPLICIT in that case.

llvm-svn: 290831
2017-01-02 20:15:33 +00:00
Saleem Abdulrasool 8bcade547a locale: update ctype access for MSVC CRT 14+
Visual C++ 14 and newer split msvcrt into msvcrt and ucrt with flavours
of the ucrt for different environments.  This changed the access to the
ctype table by introducing the `__pctype_func` and `__pwctype_func`
accessors.  Use this rather than directly accessing `_ctype` which
allows us to be safer in threaded situations by going through the libc
locking.

llvm-svn: 290823
2017-01-02 18:41:48 +00:00
Saleem Abdulrasool 61bce47e3b build: differentiate between building for and on Windows
This is necessary to support cross-compiling a Windows libc++ from
Linux.  The CMAKE_SYSTEM_HOST_NAME tells you what, in autotools
parlance, is known as the build as opposed to WIN32 which maps to, in
autotools parlance, host.

llvm-svn: 290800
2017-01-01 20:20:36 +00:00
Saleem Abdulrasool 2177f3ce5f clean up some qualifier casting
This cleans up the `-Wqual-cast` warnings from gcc 6 when building
libc++.  NFC.

llvm-svn: 290789
2016-12-31 18:13:34 +00:00
Saleem Abdulrasool 21711c451e remove some inherited attributes on exceptions
These exception types are marked with `_LIBCPP_EXCEPTION_ABI` which
expands to `__attribute__((__visibility__("default")))` or
`__declspec(dllexport)`.  When building for Windows, we would hit an
error:

    cannot apply 'dllexport' to a 'dllexport' class

Remove the duplicate annotations as they will be inherited from the
class.

llvm-svn: 290785
2016-12-31 17:34:26 +00:00
Sebastian Pop 9070500633 improve performance of string::find
string::find used to call the generic algorithm ::find.  The patch special
case string::find such that it ultimately gets converted to calls to memchr
and memcmp.

The patch improves the performance of the string::find routine by about 20x.

Without the patch, the performance on an x86_64-linux 3400 MHz machine is:

Benchmark                           Time           CPU Iterations
-----------------------------------------------------------------
BM_StringFindNoMatch/10             4 ns          4 ns  166421326
BM_StringFindNoMatch/64            37 ns         37 ns   18754392
BM_StringFindNoMatch/512          268 ns        268 ns    2586060
BM_StringFindNoMatch/4k          2143 ns       2144 ns     328342
BM_StringFindNoMatch/32k        16910 ns      16917 ns      40623
BM_StringFindNoMatch/128k       67577 ns      67602 ns      10138
BM_StringFindAllMatch/1             3 ns          3 ns  265163471
BM_StringFindAllMatch/8             6 ns          6 ns  112582467
BM_StringFindAllMatch/64           36 ns         36 ns   19566457
BM_StringFindAllMatch/512         209 ns        209 ns    3318893
BM_StringFindAllMatch/4k         1618 ns       1618 ns     432963
BM_StringFindAllMatch/32k       12909 ns      12914 ns      54317
BM_StringFindAllMatch/128k      48342 ns      48361 ns      13922
BM_StringFindMatch1/1           33777 ns      33790 ns      20698
BM_StringFindMatch1/8           33940 ns      33953 ns      20619
BM_StringFindMatch1/64          34038 ns      34051 ns      20571
BM_StringFindMatch1/512         34217 ns      34230 ns      20480
BM_StringFindMatch1/4k          35510 ns      35524 ns      19752
BM_StringFindMatch1/32k         46438 ns      46456 ns      15030
BM_StringFindMatch2/1           33839 ns      33852 ns      20648
BM_StringFindMatch2/8           33950 ns      33963 ns      20594
BM_StringFindMatch2/64          33846 ns      33859 ns      20668
BM_StringFindMatch2/512         34023 ns      34036 ns      20279
BM_StringFindMatch2/4k          35422 ns      35436 ns      19716
BM_StringFindMatch2/32k         46570 ns      46588 ns      15027

With the patch applied

Benchmark                           Time           CPU Iterations
-----------------------------------------------------------------
BM_StringFindNoMatch/10             5 ns          5 ns  133724346
BM_StringFindNoMatch/64             6 ns          6 ns  119312184
BM_StringFindNoMatch/512           13 ns         13 ns   51539628
BM_StringFindNoMatch/4k            77 ns         77 ns    8935934
BM_StringFindNoMatch/32k          551 ns        551 ns    1222808
BM_StringFindNoMatch/128k        2684 ns       2685 ns     259957
BM_StringFindAllMatch/1             7 ns          7 ns   98017959
BM_StringFindAllMatch/8             7 ns          7 ns   91466911
BM_StringFindAllMatch/64            8 ns          8 ns   85707392
BM_StringFindAllMatch/512          20 ns         20 ns   34490895
BM_StringFindAllMatch/4k           93 ns         93 ns    7360375
BM_StringFindAllMatch/32k         827 ns        828 ns     829944
BM_StringFindAllMatch/128k       3593 ns       3594 ns     195815
BM_StringFindMatch1/1            1332 ns       1332 ns     516354
BM_StringFindMatch1/8            1336 ns       1336 ns     495876
BM_StringFindMatch1/64           1338 ns       1339 ns     516656
BM_StringFindMatch1/512          1357 ns       1357 ns     510717
BM_StringFindMatch1/4k           1485 ns       1486 ns     461228
BM_StringFindMatch1/32k          2235 ns       2236 ns     318253
BM_StringFindMatch2/1            1335 ns       1335 ns     517105
BM_StringFindMatch2/8            1336 ns       1337 ns     518004
BM_StringFindMatch2/64           1344 ns       1345 ns     511751
BM_StringFindMatch2/512          1361 ns       1361 ns     508150
BM_StringFindMatch2/4k           1611 ns       1611 ns     463388
BM_StringFindMatch2/32k          2187 ns       2187 ns     317532

Patch written by Aditya Kumar and Sebastian Pop.

Differential Revision: https://reviews.llvm.org/D27068

llvm-svn: 290761
2016-12-30 18:01:36 +00:00
Eric Fiselier 1b06dfe7b7 Recommit r290750: Fix PR19460 - std::ios is convertible to int.
There were two problems with the initial fix.

1. The added tests flushed out that we misconfigured _LIBCPP_EXPLICIT with GCC.

2. Because the boolean type was a member function template it caused weird link
   errors. I'm assuming due to the vague linkage rules. This time the bool type
   is a non-template member function pointer. That seems to have fixed the
   failing tests. Plus it will end up generating less symbols overall, since
   the bool type is no longer per instantiation.

original commit message below
-----------------------------

std::basic_ios has an operator bool(). In C++11 and later
it is explicit, and only allows contextual implicit conversions.

However explicit isn't available in C++03 which causes std::istream (et al)
to have an implicit conversion to int. This can easily cause ambiguities
when calling operator<< and operator>>.

This patch uses a "bool-like" type in C++03 to work around this. The
"bool-like" type is an arbitrary pointer to member function type. It
will not convert to either int or void*, but will convert to bool.

llvm-svn: 290754
2016-12-30 14:05:52 +00:00
Eric Fiselier 03226c5e06 Revert r290750 - Fix PR19460 - std::ios is convertible to int.
llvm-svn: 290752
2016-12-30 13:11:17 +00:00
Eric Fiselier 2131a71c05 Fix PR19460 - std::ios is convertible to int.
std::basic_ios has an operator bool(). In C++11 and later
it is explicit, and only allows contextual implicit conversions.

However explicit isn't available in C++03 which causes std::istream (et al)
to have an implicit conversion to int. This can easily cause ambiguities
when calling operator<< and operator>>.

This patch uses a "bool-like" type in C++03 to work around this. The
"bool-like" type is an arbitrary pointer to member function type. It
will not convert to either int or void*, but will convert to bool.

llvm-svn: 290750
2016-12-30 12:44:58 +00:00
Ed Schouten 0a92402436 Remove mblen(), mbtowc() and wctomb() from the thread-unsafe functions.
Back in r240527 I added a knob to prevent thread-unsafe functions from
being exposed. mblen(), mbtowc() and wctomb() were also added to this
list, as the latest issue of POSIX doesn't require these functions to be
thread-safe.

It turns out that the only circumstance in which these functions are not
thread-safe is in case they are used in combination with state-dependent
character sets (e.g., Shift-JIS). According to Austin Group Bug 708,
these character sets "[...] are mostly a relic of the past and which
were never supported on most POSIX systems".

Though in many cases the use of these functions can be prevented by
using the reentrant counterparts, they are the only functions that allow
you to query whether the locale's character set is state-dependent. This
means that omitting these functions removes actual functionality.

Let's be a bit less pedantic and drop the guards around these functions.

Links:
http://austingroupbugs.net/view.php?id=708
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2037.htm

Reviewed by:	ericwf
Differential Revision:	https://reviews.llvm.org/D21436

llvm-svn: 290748
2016-12-30 10:44:00 +00:00
Eric Fiselier d566c34526 Fix PR31489 - std::function self-swap segfaults
llvm-svn: 290721
2016-12-29 20:03:55 +00:00
Eric Fiselier 99940720c8 Fix typo in comment
llvm-svn: 290666
2016-12-28 11:09:18 +00:00
Eric Fiselier b9565705bd Fix ABI incompatible C++03 nullptr_t
In C++03 libc++ emulates nullptr_t using a class, and #define's nullptr.
However this makes nullptr_t mangle differently between C++03 and C++11.
This breaks any function ABI which takes nullptr_t.

Thanfully Clang provides __nullptr in all dialects. This patch adds
an ABI option to switch to using __nullptr in C++03. In a perfect world
I would like to turn this on by default, since it's just ABI breaking fix
to an ABI breaking bug.

llvm-svn: 290662
2016-12-28 09:50:23 +00:00
Eric Fiselier d5ae0257f2 Ensure <__debug> gets the nullptr definition in C++03
llvm-svn: 290658
2016-12-28 06:15:01 +00:00
Eric Fiselier 2e519579f7 Fix debug mode for vector/list and cleanup tests
llvm-svn: 290657
2016-12-28 06:06:09 +00:00
Eric Fiselier 8dd73d8e06 Fix stupid build error caused by a stupid person
llvm-svn: 290656
2016-12-28 05:56:16 +00:00
Eric Fiselier 780b51df1d Add tests for unordered container tests and std::string
llvm-svn: 290655
2016-12-28 05:53:01 +00:00
Eric Fiselier 14bd0bf008 Fix __wrap_iter in debug mode and apply _NOEXCEPT_DEBUG to it
llvm-svn: 290654
2016-12-28 05:35:32 +00:00
Eric Fiselier c842c8d88c Fix build errors in C++03 caused by recent debug changes
llvm-svn: 290653
2016-12-28 05:26:56 +00:00
Eric Fiselier ab768a85f6 Fix debug mode build w/o exceptions
llvm-svn: 290652
2016-12-28 05:20:27 +00:00
Eric Fiselier 687d3213f0 Implement a throwing version of _LIBCPP_ASSERT.
This patch implements changes to allow _LIBCPP_ASSERT to throw on failure
instead of aborting. The main changes needed to do this are:

1. Change _LIBCPP_ASSERT to call a handler via a replacable function pointer
   instead of calling abort directly. Additionally this patch implements two
   handler functions, one which aborts and another that throws an exception.

2. Add _NOEXCEPT_DEBUG macro for disabling noexcept spec on function which
   contain _LIBCPP_ASSERT. This is required in order to prevent assertion
   failures throwing through a noexcept function. This macro has no effect
   unless _LIBCPP_DEBUG_USE_EXCEPTIONS is defined.

Having a non-aborting _LIBCPP_ASSERT is very important to allow sane testing of
debug mode. Currently we can only have one test case per file, since the test
case will cause the program to abort. Testing debug mode this way would require
thousands of test files, most of which would be 95% boiler plate. I don't think
this is a feasible strategy. Fortunately using a throwing debug handler solves
these issues.

Additionally this patch rewrites the documentation for debug mode.

llvm-svn: 290651
2016-12-28 04:58:52 +00:00
Eric Fiselier 14b1bcc14b Implement P0435R1 - Resolving LWG issues for common_type
llvm-svn: 290627
2016-12-27 21:16:48 +00:00
Eric Fiselier b6d0b83cd2 Fix PR31481 - 3+ parameter common_type isn't SFINAE friendly
llvm-svn: 290624
2016-12-27 19:59:50 +00:00
Shoaib Meenai fe1aacd014 [libc++] Make __num_get_float hidden
It's an internal function and shouldn't be exported. It's also a source
of discrepancy in the published ABI list; these symbols aren't exported
for me on CentOS 7 or Ubuntu 16.04, leading to spurious check-cxx-abilist
failures.

Differential Revision: https://reviews.llvm.org/D27153

llvm-svn: 290503
2016-12-24 18:05:32 +00:00
Marshall Clow da520dcbeb Fix bug #31387 - not checking end iterator when parsing decimal escape. Thanks to Karen for the report.
llvm-svn: 290500
2016-12-24 17:21:03 +00:00
Eric Fiselier 82ad195ad5 Avoid unused warning in __throw_future_error w/o exceptions enabled
llvm-svn: 290479
2016-12-24 01:56:25 +00:00
Eric Fiselier aec0878403 fix sign comparison warnings
llvm-svn: 290469
2016-12-24 00:24:44 +00:00
Eric Fiselier fd83822741 Fix unused parameters and variables
llvm-svn: 290459
2016-12-23 23:37:52 +00:00
Eric Fiselier 3f9b557ddd Fix PR31440: Make __sanitizer_annotate_contigious_container always visible. Fix from Jan Beich
llvm-svn: 290447
2016-12-23 20:03:52 +00:00
Chris Bieneman ca7d19e595 [CMake] Fix issue reported on sanitizer bots
This should resolve an issue reported on the commit thread that impacted sanitizer bots.

llvm-svn: 290052
2016-12-17 21:28:24 +00:00
Chris Bieneman 6c29367330 [CMake] Put headers relative to clang
When libcxx isn't building with an installed LLVM we copy the libcxx headers into the LLVM build directory so that a clang in that build tree can find the headers relative to itself.

This is only important in situations where you don't have headers installed under /, which is common these days on Darwin.

llvm-svn: 289963
2016-12-16 17:30:51 +00:00
Eric Fiselier 347a1cc221 Revert r289727 due to PR31384
This patch reverts the changes to tuple which fixed construction from
types derived from tuple. It breaks the code mentioned in llvm.org/PR31384.
I'll follow this commit up with a test case.

llvm-svn: 289773
2016-12-15 06:34:54 +00:00