Commit Graph

1786 Commits

Author SHA1 Message Date
Saleem Abdulrasool b455a8331c Revert "threading_support: make __thread_sleep_for be alertable"
This reverts SVN r295329.  Although `__libcpp_thread_sleep_for` should
be alertable, the implementation causes a large regression in the test
suite.  Add a FIXME item there for now to get the test suite in a better
state before attempting to fix that behaviour.

llvm-svn: 295561
2017-02-18 19:28:43 +00:00
Saleem Abdulrasool af14a631d0 math: add type promoting template definition on MSVCRT
When building with MSVCRT, we need to manually provide the type
promoting overloads to allow the correct type deduced invocation for
signbit(Int) and fpclassify(int).

llvm-svn: 295559
2017-02-18 19:28:38 +00:00
Saleem Abdulrasool 2d014f8106 math: fix typo in macro
MAJOR was misspelt as NAJOR.  Fix the spelling.

llvm-svn: 295510
2017-02-17 23:08:44 +00:00
Saleem Abdulrasool f45638beba cmath: Use c99 math on a new enough msvcrt
MSVCRT 14+ supports the C99 math routines that we need.  Use them
accordingly.

llvm-svn: 295509
2017-02-17 23:08:42 +00:00
Eric Fiselier 3c35491f02 Update all bug URL's to point to https://bugs.llvm.org/...
llvm-svn: 295434
2017-02-17 08:37:03 +00:00
Eric Fiselier 7f1604aae6 Use inline namespaces with GCC instead of __attribute__((__strong__)).
GCC 7.0.1 started warning that __attribute__((__strong__)) is depricated.
This patch switches to using inline namespace with GCC instead. I believe
this wasn't done originally in order to support older GCC versions w/o
support for inline namespaces, or because earlier versions of GCC warned
users that the STL was using an inline namespace (even though it shouldn't affect users).

However I believe all of the above problems are gone for GCC 4.9 and greater.
Therefore switching to using inline namespaces instead of using __strong__
is the most correct behavior.

llvm-svn: 295428
2017-02-17 07:31:38 +00:00
Eric Fiselier 07e93d3b00 Add doc for _LIBCPP_ENABLE_CXX17_DISABLED_AUTO_PTR and make it work under _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
llvm-svn: 295407
2017-02-17 03:30:25 +00:00
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